我是 SQL Server 的新手,并尝试使用 SQL Server 为以下场景创建查询。
我有一个名为的表,其中包含可以使用GenericLabels
的所有标签 () 的列表。varchar(30)
它们用于名为 的表中UserDeviceStatus
。我想要给定的标签列表,其中包含GenericLabels
但未使用的标签。UserDeviceStatus
UserId
我创建了以下查询
select label
from GenericLabels
where not exists (select customlabel from UserDeviceStatus where userid = 40)
此查询返回空结果
这是带有单个查询的输出。
select label from GenericLabels
返回
Aux1
Aux2
Aux3
Aux4
Aux5
Aux6
和
select customlabel from userdevicestatus where userid = 40
返回
Aux2
Aux3
我想要以下结果
Aux1
Aux4
Aux5
Aux6