2011-04-13 54 views
4
Select Distinct 
    SomeDay.SomeDayID, SomeDay.FolderName, SomeDay.FolderColor 
from 
    SomeDay, SomeDayEvent 
where 
    SomeDay.SomeDayID != 4,3,2,1; 

回答

4

不能使用!=多個值,你應該使用not in像:

Select Distinct 
    SomeDay.SomeDayID,SomeDay.FolderName,SomeDay.FolderColor 
from 
    SomeDay,SomeDayEvent 
where 
    SomeDay.SomeDayID not in (4,3,2,1); 
0

Select Distinct SomeDay.SomeDayID,SomeDay.FolderName,SomeDay.FolderColor from SomeDay,SomeDayEvent where SomeDay.SomeDayID NOT IN (4, 3, 2, 1)

使用IN子句。

4

您不能用逗號分隔WHERE部分中的值。您必須使用IN或BETWEEN關鍵字。

SomeDay.SomeDayID NOT IN (1,2,3,4) 

SomeDay.SomeDayID NOT BETWEEN 1 AND 4 
0

SomeDayID可空?你應該知道表達式

NULL NOT IN (1, 2, 3, 4) 

不計算爲TRUE。