【发布时间】:2022-01-15 00:17:12
【问题描述】:
我有一个personnel 表。我想获取此表中的所有记录,除了 IT 值为部门且名称为 John 的记录。
这些是我的行:
| Name | Department |
|---|---|
| John | Computer |
| John | IT |
| Kevin | Medical |
| Kevin | IT |
| Kevin | Pharmacy |
这是我的查询
select *
from personnels per
where (per.Name = 'John' and per.Department <> 'IT')
这是该查询的结果:
| Name | Department |
|---|---|
| John | Computer |
预期结果
| Name | Department |
|---|---|
| John | Computer |
| Kevin | Medical |
| Kevin | IT |
| Kevin | Pharmacy |
【问题讨论】:
标签: sql sql-server tsql