[英]MYSQL query not working as expected
I have the following mysql query--- 我有以下mysql查询-
$query="SELECT * FROM `wall_posts`
WHERE
`login_name` = '" . $_SESSION['SESS_LOGIN'] . "'
OR
`login_name` IN (
SELECT friend_login
FROM friends
)
ORDER BY time DESC";
But when I execute it, it does'nt give me expected results also only one post is being displayed! 但是,当我执行它时,它并没有给我预期的结果,而且只显示了一篇帖子!
Have you tried running it directly from within a mysql console/phpmyadmin? 您是否尝试过直接从mysql console / phpmyadmin内部运行它?
And what is in friends
? friends
什么? Is it a relation table? 是关系表吗? In that case you should probably add a WHERE
somewhere because now you are selecting everything. 在这种情况下,您可能应该在某处添加WHERE
,因为现在您正在选择所有内容。
This code should return more then just 1 row if there are more. 如果有更多行,此代码应返回更多行,然后仅返回一行。 Perhaps your problem is in the way you display the results. 也许您的问题出在显示结果的方式上。 What is the result of: 结果是什么:
$result = mysql_query($query);
echo 'Number of rows: ' . mysql_num_rows($result);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.