[英]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. 我有一个文章页面,我只想向用户显示每个帐户都在关注的提要,有点像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. 我必须区分表,一个被称为
posts
另一个被称为followers
我想循环文章,但我希望它仅选择我的帐户所关注的用户。 I just need the SQL
query that can do that since the PHP
part of the rest i can perform it 我只需要可以执行此操作的
SQL
查询,因为其余的PHP
部分我可以执行它
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")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.