I have a table called review
:
review_id cat_id public_or_private
1 1 0
11 2 2
12 3 1
13 4 2
14 5 2
And a table called category
:
cat_id user_id
1 10298
2 10299
3 10300
4 10299
5 10298
My statement:
$sql2 = "SELECT *
FROM review
INNER JOIN category ON review.cat_id = category.cat_id
WHERE review.public_or_private = 2";
This will give me the result:
review_id cat_id public_or_private cat_id user_id
11 2 2 2 10299
13 4 2 4 10299
14 5 2 5 10298
contacts
table:
user_id contact_id
10299 10298
10299 10300
10300 10298
10300 10301
How can I hone this further? : I only want results if user_id
is not in the contact_id
column of the contacts
table.
So from user 10300
point of view the result should be:
review_id cat_id public_or_private cat_id user_id
11 2 2 2 10299
13 4 2 4 10299
I believe I should be using NOT EXISTS
or NOT IN
but not sure how I should put it.