0

当我想选择所有的打字和在线用户(1)除了一个ID为4的用户之外,我怎么能在MySQL中说呢?我想要 id= 4 的用户名而不是打字

我试过 NOT IN 但我猜它不适合我。

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

点击图片了解更多信息

4

2 回答 2

0

我会使用这样的连接:

SELECT username, typing FROM members members LEFT OUTER JOIN typing typing WHERE members.status = 1 AND typing.id <> 4
于 2013-05-16T01:39:39.703 回答
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
于 2013-05-16T01:40:47.220 回答