:)
这是我的“聊天”表:ID - FROM - TO - MSG - DATE - RECU
我想列出所有与 $username 聊天的用户。$username 在“FROM”中的位置:(为便于阅读添加了换行符)
$sql = "SELECT *
FROM chat
WHERE chat.from = '$username' AND chat.to != '$username'
GROUP BY chat.to
ORDER BY chat.to ASC";
$username 在“TO”中的位置:
$sql = "SELECT *
FROM chat
WHERE chat.from != '$username' AND chat.to = '$username'
GROUP BY chat.from
ORDER BY chat.from ASC";
我现在可以列出这 2 个表,但是如何只提出一个请求或仅列出 1 个表?用 UNION 区分???
谢谢!:)