I have the following MySql Table:
--------------------------------------------
Table 'category'
--------------------------------------------
category_id name parent_id
1 animal NULL
2 vegetable NULL
3 mineral NULL
4 dog 1
6 cat 1
7 carrot 2
8 quartz 3
The following SQL Statement will list all results like this:
category_id category sub_category
4 animal dog
6 animal cat
7 vegetable carrot
8 mineral quartz
SELECT sub_category.category_id AS category_id,
category.name AS category,
sub_category.name AS sub_category
FROM category
LEFT OUTER JOIN category AS sub_category
ON sub_category.parent_id = category.category_id
WHERE category.parent_id IS NULL
ORDER BY category_id
But now I have another table with categories that particular users are NOT interested in:
--------------------------------------------
Table 'category_filter'
--------------------------------------------
user_id category_id
1 4
1 7
1 8
How can I make a query for one particular user so that I get a list of all categories with an info whether a user is interested or not?
Something like this for example:
--------------------------------------------------------------
category_id category sub_category interested
4 animal dog NULL
6 animal cat 6
7 vegetable carrot 7
8 mineral quartz NULL
Thanks in advance for your support.