can i use != instead of 'NOT IN' eg. SELECT*FROM table_name WHERE city != ('La', 'ny', 'lag'); | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

can i use != instead of 'NOT IN' eg. SELECT*FROM table_name WHERE city != ('La', 'ny', 'lag');

SQL logical statement

5th Jan 2017, 4:22 PM
Oyelakin Dotun Peter
Oyelakin Dotun Peter - avatar
2 Answers
+ 2
No, because != will do an exact comparison of the value in the city field. Most likely, this syntax won't be valid (currently not at a computer), but even if it was, it would return everything that didn't have a city called ('La','ny','lag'), so every row would be returned, which isn't what you'd expect.
5th Jan 2017, 4:48 PM
Adam Ambrose
Adam Ambrose - avatar
+ 1
no. because not in is a group function but != is for single value. So you cant use when you need array kind of value
10th Jan 2017, 5:42 AM
Vinayak Moger
Vinayak Moger - avatar