I'm running the following query to select all posts liked by a user. The problem is, it takes quite a few seconds for the page to load.
SELECT p.*, a.username, a.avatar FROM user_posts p
LEFT JOIN account a ON p.uid=a.id WHERE p.pid in
(select post from user_posts_likes where `by`='$user_id')
ORDER BY `pid` DESC LIMIT $npage, 10";
Is there a better way to do this instead of using WHERE IN?
Thanks.