Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql ms access sql语句选择角色为a而不是b的用户_Mysql_Ms Access - Fatal编程技术网

Mysql ms access sql语句选择角色为a而不是b的用户

Mysql ms access sql语句选择角色为a而不是b的用户,mysql,ms-access,Mysql,Ms Access,我想选择具有角色A和/或B但不具有角色c的用户。我尝试了这个查询,但不起作用 SELECT User from table1 where (role ="A" or role = "B") and (Role <> "C"). 从表1中选择用户,其中(role=“A”或role=“B”)和(role“C”)。 用户可以有多个角色。然后可以有ABC,AC,AB…我想如果你省略角色“C”它只会得到角色=A和角色=B的行。另外,查看文档,您的(role=“A”或role=“B”)上的括

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

SELECT User from table1 where (role ="A" or role = "B") and (Role <> "C").
从表1中选择用户,其中(role=“A”或role=“B”)和(role“C”)。

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

我想如果你省略
角色“C”
它只会得到
角色=A和角色=B的行。另外,查看文档,您的
(role=“A”或role=“B”)
上的括号似乎是不必要的。

我认为,如果您省略
角色“C”
,它只会得到带有
角色=A和角色=B的行。另外,看看这些文档,您的
(role=“A”或role=“B”)
上的括号似乎是不必要的。

谢谢各位,我找到了答案

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;

谢谢,伙计们,我知道了

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;

当你说他们可以有多个角色时,你的意思是该列字面上可以有“ABC”值吗?看起来需要重新设计。如果一个用户可以有多个角色,那么按照惯例,你几乎肯定应该有一个“角色”表,它与“用户”表有1:多的关系当你说他们可以有多个角色时,您的意思是该列字面上可以有“ABC”值吗?看起来需要重新设计。如果一个用户可以有多个角色,那么按照惯例,您几乎肯定应该有一个“角色”表,它与“用户”表有1:多的关系