Thanks a lot Michael. A regular join did not seem to work. But when I tried a LEFT JOIN it worked.
A cut down example of it is the following.
SELECT global_lead.id, rep_no, es.fname as sales_name, em.fname as marketing_name
FROM global_lead
LEFT JOIN global_employee es ON global_lead.rep_no = es.id
LEFT JOIN global_employee em ON global_lead.entered_by = em.id
WHERE global_lead.rep_no = 8
Michael Stassen wrote:
You need to join the employee table twice, once for each id lookup, like this:
SELECT es.name AS sales_name, em.name AS marketing_name, leads.id FROM leads JOIN employee es ON leads.salesid = es.id JOIN employee em ON leads.marketingid = em.id;
Michael
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]