Advertisement
Guest User

vote and comment query

a guest
Oct 14th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.33 KB | None | 0 0
  1. SELECT post.id as postId, post.title AS userpost, user.username AS user, COUNT(comment.`fk_post`) as NumberOfComments, SUM(vote_post.`amount`) as NumberOfVotes, post.url, post.time
  2. FROM user
  3. JOIN post ON user.id = post.fk_user
  4. join comment on comment.`fk_post` = post.id
  5. join vote_post on vote_post.`fk_post` = post.id
  6. GROUP BY post.id
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement