I have two tables I want to join.
I want all of the categories in the categories table and also all of the categories subscribed to by a user in the category_subscriptions table.
essentially this is my query so far:
SELECT *
FROM catagories
LEFT JOIN user_category_subscriptions
ON user_category_subscriptions.category_id = catagories.category_id
This works fine however I want to add a where clause on the end of the query which then essentially makes it an inner/equi join.
SELECT *
FROM catagories
LEFT JOIN user_category_subscriptions
ON user_category_subscriptions.category_id = catagories.category_id
WHERE user_category_subscriptions.user_id = 1
How do I get all the categories as well as all the categories subscribed to by a particular user using only one query?
category_id being a key in both catagories table and user_category_subscriptions. user_id residing in the user_category_subscriptions table.
thanks