hi! what's the diference between ' != ' and ' NOT ' ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

hi! what's the diference between ' != ' and ' NOT ' ?

9th Apr 2016, 9:45 AM
Eleonora
8 Answers
+ 15
There is a difference. NOT, as was pointed out, is a logical operator, and as such, you can use it with various conditions. != is a simple comparison with a certain value. Examples: SELECT name, age, city, job FROM people WHERE city != 'London'; will give you people from all cities except London. SELECT name, age, city, job FROM people WHERE age >18 AND NOT (city IN ('Sydney', 'Tokyo') AND job = 'Student') will give you people who are older than 18, except Students from Sydney or Tokyo. In a very specific query, the two operators will give the same results (as will <> by the way, which is identical to !=): SELECT name, city FROM people WHERE city != 'London'; SELECT name, city FROM people WHERE city <> 'London'; SELECT name, city FROM people WHERE NOT (city = 'London'); will all return the same set.
1st Aug 2016, 8:45 AM
MrAwesome
+ 11
NOT is logical expression which gives complement of any number whereas != means not equals to.
24th Jun 2016, 6:52 AM
shailesh kumar
shailesh kumar - avatar
+ 2
1) NOT is a logical operator. It is applied on conditions. Example : NOT (a>b) is true if the condition 'a>b' is false. 2) != is a comparison operator. It can be used in conditions. Example : (a!=b) is a condition and is true if 'a' is not equal to 'b'. Simply stating, NOT is applied on conditions whereas != is used to form a condition.
5th Jan 2017, 2:08 PM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 1
there is no difference . the only thing is that "!=" is used in C++ and "NOT" is used in database...
8th Jul 2016, 8:16 AM
Ajay Chauhan
Ajay Chauhan - avatar
+ 1
I've seen the Not operator expressed as <> as well as != , is there a difference in using these operators? ( just piggybacking here)
15th Jul 2016, 3:31 PM
Alric Burke
Alric Burke - avatar
0
how to delete duplicate row from table?
12th Aug 2016, 7:00 AM
Dnyaneshwar Godge
0
thank you guys for all these answers it really helped me know the difference
5th Jan 2017, 2:52 PM
Mohamed Nabawy
0
output of both the statements are same but the syntax may be different.
22nd Jan 2017, 10:51 PM
mahendra mahajan
mahendra mahajan - avatar