这有效......
$sql30 = "SELECT * FROM statuses LEFT JOIN friends ON statuses.userID=friends.lowerFriendID WHERE friends.lowerFriendID != :user_ida
UNION SELECT * FROM statuses RIGHT JOIN friends ON statuses.userID=friends.higherFriendID WHERE friends.higherFriendID != :user_idb ORDER BY userID DESC";
但我不需要按userID排序,这不起作用......
$sql30 = "SELECT * FROM statuses LEFT JOIN friends ON statuses.userID=friends.lowerFriendID WHERE friends.lowerFriendID != :user_ida
UNION SELECT * FROM statuses RIGHT JOIN friends ON statuses.userID=friends.higherFriendID WHERE friends.higherFriendID != :user_idb ORDER BY id DESC";
也不是......
$sql30 = "SELECT * FROM statuses LEFT JOIN friends ON statuses.userID=friends.lowerFriendID WHERE friends.lowerFriendID != :user_ida
UNION SELECT * FROM statuses RIGHT JOIN friends ON statuses.userID=friends.higherFriendID WHERE friends.higherFriendID != :user_idb ORDER BY `id` DESC";
也不是......
$sql30 = "SELECT * FROM statuses LEFT JOIN friends ON statuses.userID=friends.lowerFriendID WHERE friends.lowerFriendID != :user_ida
UNION SELECT * FROM statuses RIGHT JOIN friends ON statuses.userID=friends.higherFriendID WHERE friends.higherFriendID != :user_idb ORDER BY timestamp DESC";
我需要通过“id”或“timestamp”DESC进行排序,以便最新的帖子首先显示。非常感谢您的帮助。谢谢!