Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/73.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/4/sql-server-2008/3.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
如何生成此SQL Select子句?_Sql_Sql Server 2008_Select - Fatal编程技术网

如何生成此SQL Select子句?

如何生成此SQL Select子句?,sql,sql-server-2008,select,Sql,Sql Server 2008,Select,我需要帮助把这个问题翻译成英语。 我有一个带有DEVICEID列的表设备,还有一个带有DEVICEID、CLONEID、PATH和VALUE列的表克隆 我想得到没有链接到克隆的设备,其中路径在硬编码集中,我们可以称为8个硬编码值,路径的值不在B中 能帮我想清楚吗 我的第一次尝试是 SELECT d FROM device d, clone c WHERE d.deviceid = c.deviceid AND (c.path = 'a[1]' OR c.pa

我需要帮助把这个问题翻译成英语。 我有一个带有DEVICEID列的表设备,还有一个带有DEVICEID、CLONEID、PATH和VALUE列的表克隆

我想得到没有链接到克隆的设备,其中路径在硬编码集中,我们可以称为8个硬编码值,路径的值不在B中

能帮我想清楚吗

我的第一次尝试是

SELECT d 
    FROM device d, clone c 
    WHERE d.deviceid = c.deviceid 
        AND (c.path = 'a[1]' OR c.path = 'a[2]' ... ) 
        AND x.value not in B
但每个路径的OR值都不正确

假设A和B是值列表

select d from device d where not exists (select c.device_id from
clone c where d.deviceid = c.deviceid and c.path in (A) and
c.value not in (B)
)
Select d 
from device d
where not exists (select * from clone c where c.deviceid=d.deviceid 
and (c.path = 'a[1]' OR c.path = 'a[2]')
        and c.value not in ('hardcoded list')
        )