2013-11-22 32 views
1

我需要幫助使這個查詢成爲英語甚至。 我有一個表DEVICEDEVICEID列,並且表CLONE與列DEVICEID,CLONEID,PATH,和VALUE如何製作此SQL Select子句?

我想是鏈接到CLONE其中PATH是在硬編碼組設備,我們可以調用A(8硬編碼值)和PATH'sVALUEB

我可以幫助我思考這個問題嗎?

我第一次嘗試是

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 

但或者每個路徑不正確。

回答

0

假設AB是值的列表

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) 
) 
0
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') 
     )