Help with MySQL table job
Posted: Mon Dec 08, 2008 12:32 am
First of all here is my MySQL. I've cut it down a little bit for easy reading:
Basically I need to join the first two tables: leads_tasks and leads. The third table (proposals_sent) is optional dependent on if there is any data from it. I only want to join it if there is anything that matches the t.database_id to p.proposal_id. If not, I just want it to join the first two tables and pull results from them.
However, with my current code, if there is nothing in the proposals_sent table, it says there are no rows.
I think I have to use LEFT JOIN or something like that but I'm not sure. Any help would be appreciated
Code: Select all
SELECT * FROM leads_tasks AS t
JOIN leads AS l ON t.lead_id = l.id
JOIN proposals_sent AS p ON t.database_id = p.proposal_id
WHERE ....However, with my current code, if there is nothing in the proposals_sent table, it says there are no rows.
I think I have to use LEFT JOIN or something like that but I'm not sure. Any help would be appreciated