Answer the question
In order to leave comments, you need to log in
How to pull out posts where 'likes > 10' (likes in another table, posts in another)?
Good day. Help a newbie, I can't figure out how to organize this.
There is a _Likes table, it has 3 fields ("user_id", "post_id" which user put @ like on which post and ID)
and there is also a _posts table, it has a lot of things and of course that post_id
I want to pull out posts that scored more than 10 likes. How can I do it ?
how? php or sql query? show examples please indicate the correct path
Answer the question
In order to leave comments, you need to log in
I'm working with MS Sql server, not MySQL, so your syntax may be different, but the idea is this:
Make a grouping in the likes table by post_id
you will get post_id's that have more than 10 likes. You can then use this as a subquery.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question