mysql - Selecting the data that isn't in a query -
I want to select all those posts that are not marked as read by the user.
pre> I want to select all the data that is not selected in this query I want to be like output you can not If you want to exclude only the post whose user has read 3, you can add a user_id post_id 3 1 3 4
SELECT p. post_id, p.post_message FROM tbl_post as p LEFT JOIN tbl_mark_as_read AS r.post_id = p.post_id and r.user_id = 3
post_id post_message 2 goodnight 3 good morning cool
not in op RATER:
SELECT * fROM tbl_post Do not post in the WHERE (SELECT post_id FROM tbl_mark_as_read);
where section to the internal query:
SELECT * fROM tbl_post WHERE do not post_in (SELECT post_id FROM tbl_mark_as_read WHERE user_id = 3);
Comments
Post a Comment