Using multiple values ​​in a SQL query, where the condition

Select Distinct SomeDay.SomeDayID, SomeDay.FolderName, SomeDay.FolderColor from SomeDay, SomeDayEvent where SomeDay.SomeDayID != 4,3,2,1; 
+4
source share
4 answers

You cannot use != For multiple values ​​for which you should use not in , for example:

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

You cannot separate values ​​in the WHERE part by comma. You must use the keyword IN or BETWEEN.

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

or

 SomeDay.SomeDayID NOT BETWEEN 1 AND 4 
+4
source

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

Use the IN clause.

0
source

Is SomeDayID valid? You should know that expression

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

does not evaluate to TRUE.

0
source

Source: https://habr.com/ru/post/1347903/


All Articles