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> user_id post_id 3 1 3 4

I want to select all the data that is not selected in this query

  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   

I want to be like output

  post_id post_message 2 goodnight 3 good morning cool    

you can not not in op RATER:

  SELECT * fROM tbl_post Do not post in the WHERE (SELECT post_id FROM tbl_mark_as_read);   

If you want to exclude only the post whose user has read 3, you can add a 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

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -