简体   繁体   中英

MYSQL query not working as expected

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!

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

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