Code: Select all
SELECT leadid, firstname, lastname
FROM lead
LEFT JOIN user_partner ON user_partner.userid = lead.affiliateid AND (user_partner.userid = '9' OR user_partner.userid = '12')
GROUP BY leadid
ORDER BY lastname
This query should not take that long to load (I don't think), so I guess I am looking for some tips/general knowledge that I may be missing.
Bonus Question: Would storing the results in a session variable be a bad idea? That way, the data is called once, then doesn't need to be called again.