Php 两个表一个用于帖子,另一个用于相互连接的朋友如何检索朋友的帖子
我有两个表,第一个是post,其中有Php 两个表一个用于帖子,另一个用于相互连接的朋友如何检索朋友的帖子,php,mysql,sql,Php,Mysql,Sql,我有两个表,第一个是post,其中有post\u by和post columns,第二个是connectionstbl,其中有memberid并与之连接,其中member是登录用户,connectedWith是朋友 如何检索post Column的数据,其中post_by=connectedwith 下面的查询: $result=mysql_query(" select social_posts.posted_by, social_posts.po
post\u by
和post columns
,第二个是connectionstbl
,其中有memberid
并与之连接,其中member
是登录用户,connectedWith
是朋友
如何检索post Column的数据,其中post_by=connectedwith
下面的查询:
$result=mysql_query("
select
social_posts.posted_by,
social_posts.post as social_posts_post connectionstbl.connectedwith
from
social_posts,connectionstbl
where
social_posts.posted_by = connectionstbl.connectedwith
order by social_posts.p_id desc
");
while ($row =mysql_fetch_array($result))
{
echo $row['social_posts_post']."<br/>";
}
?>
$result=mysql\u查询(“
选择
社会帖子。发布者:,
社交帖子作为社交帖子发布帖子连接TBL.connectedwith
从…起
社交网站帖子、连接TBL
哪里
社交发布者=连接TBL.connectedwith
按社会职位排序。p\U id描述
");
while($row=mysql\u fetch\u数组($result))
{
echo$row['social_posts_post']。“
”;
}
?>
执行查询不会输出任何内容。您在社交帖子和连接TBL.connectedwith之间缺少一个逗号。我猜您的错误报告或显示错误配置参数设置为不显示错误,否则您会看到警告。您应该使用连接:
SELECT
p.posted_by, p.post AS social_posts_post, c.connectedwith
FROM social_posts p
JOIN connectionstbl c ON p.posted_by = c.connectedwith
ORDER BY p.p_id DESC
请正确格式化您的查询…请正确格式化您的查询并提供正确的表结构,以便我们可以帮助您