简体   繁体   中英

PHP SELECT FROM multiple tables

I have a article pages, that i only want to show feed of the users that every account is following, kinda like twitter. I have to distinct tables one is called posts other is called followers I want to loop the articles but i want it to select only the users that my account is following. I just need the SQL query that can do that since the PHP part of the rest i can perform it

Something like this , although i know that this one does not work

$connect->query("SELECT id,userid,postagem FROM posts WHERE IN (SELECT followed FROM followers WHERE whofollowed = '$userd' )  ORDER BY id DESC LIMIT 13");

假设followed者也是关注者表中的一个用户ID:

$connect->query("SELECT id,userid,postagem FROM posts WHERE userid IN (SELECT followed FROM followers WHERE whofollowed = '$userd' )  ORDER BY id DESC LIMIT 13")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM