MYSQL查询无法按预期工作

MYSQL查询无法按预期工作

问题描述:

I have the following mysql query---

               $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!

我有以下mysql查询--- p>

  $  query =“SELECT * FROM`wall_posts` 
 WHERE 
`logice_name` ='”。  $ _SESSION ['SESS_LOGIN']。  “'
 OR 
`login_name`IN(
 SELECT friend_login 
 FROM friends 
)
 ORDER BY time DESC”; 
  code>  pre> 
 
 

但是当 我执行它,它没有给我预期的结果也只显示一个帖子! p> div>

Have you tried running it directly from within a mysql console/phpmyadmin?
And what is in friends? Is it a relation table? In that case you should probably add a WHERE somewhere because now you are selecting everything.

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);