(SELECT * FROM `chats` WHERE `chat_from` = '18' AND `chat_to` = '13' ORDER BY `date_time` DESC )
UNION
(SELECT * FROM `chats` WHERE `chat_from` = '13' AND `chat_to` = '18' ORDER BY `date_time` DESC )
答案 0 :(得分:2)
试试这个
SELECT * FROM `chats`
WHERE `chat_from` IN(18,13)
AND `chat_to`IN(18,13)
ORDER BY `date_time` DESC
答案 1 :(得分:1)
select * from
(
SELECT * FROM `chats` WHERE `chat_from`in ('18','13') and `chat_to` in ('18','13')
)
t1 ORDER BY `date_time` DESC
答案 2 :(得分:0)
你可以这样做:
SELECT * FROM `chats`
WHERE
(
`chat_from` = '18'
AND `chat_to` = '13'
)
OR
(
`chat_from` = '13'
AND `chat_to` = '18'
)
ORDER BY `date_time` DESC
如果您需要它们,那么您可以使用:
SELECT DISTINCT * FROM `chats`...