我试图在两个用户之间传递第一个信息,无论我是否发出这一信息。 我提出以下问题,即回归所有正确之处,但似乎忽视了DISTINCT条款——我最后得出了相同结果。
我如何纠正这一疑问,以便不会重复在由此产生的 some栏中退还的价值?
www.un.org/Depts/DGACM/index_spanish.htm 这里指的是目前使用的Im:。
SELECT DISTINCT CASE WHEN $userid != senderid THEN senderid ELSE GROUP_CONCAT(receivers.id SEPARATOR , ) END someid,
CASE WHEN $userid != senderid THEN senders.username ELSE GROUP_CONCAT(receivers.username SEPARATOR , ) END somename,
messages.body,
messages.time
FROM messages
LEFT JOIN messages_recipients AS recipients ON messages.id = recipients.messageid
LEFT JOIN users AS senders ON messages.senderid = senders.id
LEFT JOIN users AS receivers ON recipients.userid = receivers.id
WHERE recipients.userid = $userid
OR messages.senderid = $userid
GROUP BY messages.id
ORDER BY messages.time DESC