Advertisement
Guest User

Untitled

a guest
Apr 29th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. Table Posts:
  2. id body
  3. 1 test1
  4.  
  5. Table user_views
  6. post_id user_id
  7. 1 1
  8.  
  9. select count(uv.post_id) as views_count,posts.id,posts.body from posts
  10. left join user_views uv on uv.post_id = posts.id
  11. group by posts.id
  12.  
  13. select count(*) from posts where posts.id not in select post_id from user_views where post_id = posts.id and user_id = 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement