SOLVED: Query builder join count results |
I have a table called 'posts' with id, title, author, date and post content.
I also have 2 tables called 'comments' and 'likes'. Both "sub tables" hold the post_id, user_id and datetime. Can anyone help me with a query that gives me the author, title, date, number of comments and number of likes for all posts, in one list? I'm trying to solve it with arrays that are created by 3 different queries, but something tells me I can do it a lot easier with joins. I just can't figure out how.
This could work.
Have not tested it, but found a similar question on Stack Overflow PHP Code: SELECT
Thanks! First, I got only one post title and the total number of comments and likes.
I just needed to add "GROUP BY post.id" to get that fixed.
Glad I could help & Graag gedaan
![]()
Thanks guys..was getting stuck in a similar issue myself. Your little conversation helped me out
![]()
Constantly learning.
|
Welcome Guest, Not a member yet? Register Sign In |