Join where there is sometimes no value?
Hello, I am after some help please. I have two tables, which I wish to query to output all the records in table_a.
- In table_a I have a field named 'thecategoryid'
- In table_b I have a field named 'categoryid'
But my problem is in table_a 'thecategoryid' field in each row can sometimes contain a value and sometimes not, so I can't join like so
table_a.thecategoryid = table_b.catgoryid
So how can I output all records in table_a with a join on table_b but with it not mattering if there is or there is not a value on the row 'thecategoryid'
Is this possible?
Sure you can. Just use a LEFT JOIN to fetch all records from the primary table (governed by the where clause of course), and any matching records from the child table.
|All times are GMT +1. The time now is 09:40 AM.|
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.