Reputation: 872
I've two tables level & product, basically I need to find out level.id = 1, but I also need to know if it has product attached to this id in product table. There is a pdcatid in my product table. Now the query works only if this id also in product table, if product table doesn't have this id, it will fail and retrurn empty. How can I show both situations?
Here is my query I've tried
SELECT *
FROM level
RIGHT JOIN product on level.`id` = product.`pdcatid`
WHERE level.`id` = 1
Thank You.
Upvotes: 0
Views: 30
Reputation: 236
Try this:
SELECT * FROM level LEFT JOIN product on level.`id` = product.`pdcatid` WHERE level.`id` = 1
Upvotes: 1