当我想要选择所有在线的输入和用户(1)时,我怎么能在MySQL中说,除了一个id为4的用户?我想要id = 4的用户名而不是输入
我没试过,但我猜它不适合我。
SELECT username,typing FROM members WHERE status = 1 NOT IN (SELECT typing FROM members WHERE id =4)
http://img266.imageshack.us/img266/2313/typing.png
点击图片了解更多信息
答案 0 :(得分:0)
我会使用这样的连接:
SELECT username, typing FROM members members LEFT OUTER JOIN typing typing WHERE members.status = 1 AND typing.id <> 4
答案 1 :(得分:0)
这是你想要的吗?
SELECT username,
(case when id <> 4 then typing end) as typing
FROM members
WHERE status = 1 or id = 4
根据您的图片,我认为您只想:
SELECT username, typing
FROM members
WHERE status = 1 and id <> 4