我想要实现的是这样的:
SELECT *
FROM conv
WHERE (WHERE from_user = 3 OR to_user = 3)
AND (WHERE conv = 6_3 OR conv = 3_6)
因此,有时该conv
领域的风格[from_to]
有时[to_from]
取决于谁开始了对话。我想列出由我或其他用户向我发起的会话中发送给我或发送给我的消息。
它应该像这样简单:
SELECT *
FROM conv
WHERE (from_user = 3 OR to_user = 3)
如果你想要“功夫”版本,试试这个:
SELECT *
FROM conv
WHERE 3 IN (from_user, to_user)
写WHERE
一次关键字。
SELECT * FROM conv WHERE (from_user = 3 OR to_user = 3) AND (conv = 6_3 OR conv = 3_6
只需删除多余WHERE
的 s:
SELECT *
FROM conv
WHERE (from_user = 3 OR to_user = 3)
AND (conv = "6_3" OR conv = "3_6")
conv
我还将您的值包装在"
s 中,因为 anINT
不能包含 an _
,因此它必须存储为 a VARCHAR
(因此需要"
s)。