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 categories
LEFT JOIN user_category_subscriptions
ON user_category_subscriptions.category_id = categories.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 categories
LEFT JOIN user_category_subscriptions
ON user_category_subscriptions.category_id = categories.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 categories table and user_category_subscriptions. user_id residing in the user_category_subscriptions table.
thanks