私は SQL Server を初めて使用し、SQL Server を使用して次のシナリオのクエリを作成しようとしています。
使用できるGenericLabelsすべてのラベル ( ) のリストを含むという名前のテーブルがあります。varchar(30)それらは と呼ばれるテーブルで使用されますUserDeviceStatus。特定ので使用されているGenericLabelsが使用されていないラベルのリストが必要です。UserDeviceStatusUserId
次のクエリを作成しました
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