1

我想选择具有角色 A 和/或 B 但没有角色 c 的用户。我试过这个查询,但它不起作用。

SELECT User from table1 where (role ="A" or role = "B") and (Role <> "C").

用户可以拥有多个角色。然后可以有ABC,AC,AB...

4

2 回答 2

1

谢谢各位 我想通了

SELECT DISTINCT a.User, a.ROLE
FROM table1 AS a
WHERE (((a.User) Not In (select user from table1 where
ROLE = "ROLEC" and user = a.user)) AND ((a.ROLE)="ROLEA" Or (a.ROLE)="ROLEB") 
ORDER BY a.User;
于 2012-06-23T03:43:25.310 回答
0

我认为如果你只是省略role <> "C"只会得到带有role=A and role=B. 此外,查看文档,您的括号似乎(role ="A" or role = "B")是不必要的。

于 2012-06-22T23:01:40.433 回答