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
Michael J. Pawlowsky wrote:
Im not sure if this is possible or not.
I have a Sales leads table. Part of the table has 2 employee_ids.
1. The Sales person the lead is assigned to. 2. The Marketing person that generated the lead.
Then there is a employee table that has ids and names.
When generating a report for leads I would like to lookup the name of the employee.
I know I can do it with a seperate query, but I'm wondering if I can also do it in one query.
Something like:
SELECT employee.name as sales_name, employee.name as marketing_name, leads.id
FROM leads, employee
WHERE employee.id = leads.salesid
AND employee.id = leads.marketingid
Is there someway this can be done?
Thanks for any assistance.
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]