all.md 1.0 KB
Newer Older
M
all  
Mars Liu 已提交
1 2 3 4 5 6 7
# ALL

Joe 想从员工表

```mysql
create table employee(
    id int primary key auto_increment,
M
Mars Liu 已提交
8
    dept_id int,
M
all  
Mars Liu 已提交
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
    name varchar(256),
    post varchar(16)
)
```

中找出所有其所在部门没有助理(post 为 `assistant`)的员工信息。由于 Joe 没有其它表的查询权限,他只能查询员工表,这个查询应该是:

## 答案

```mysql
select id, name, dept 
from employee as o
where 'assistant' != all(select post from employee as i where o.dept = i.dept); 
```

## 选项

### A

```mysql
select id, name, dept 
from employee as o
where 'assistant' = all(select post from employee as i where o.dept = i.dept); 
```

### B

```mysql
select id, name, dept 
from employee as o
where 'assistant' != all(select post from employee as i where o.dept = i.dept); 
```

### C
```mysql
select id, name, dept 
from employee as o
where 'assistant' != all(select post from employee as i); 
```

### D

```mysql
select id, name, dept 
from employee as o
where 'assistant' != ANY(select post from employee as i where o.dept = i.dept); 
```