Not equal operator on NULL

0 votes

Could someone please explain the following behavior in SQL?

SELECT * FROM MyTable WHERE MyColumn != NULL (0 Results)
SELECT * FROM MyTable WHERE MyColumn <> NULL (0 Results)
SELECT * FROM MyTable WHERE MyColumn IS NOT NULL (568 Results)
Sep 17 in Database by Kithuzzz
• 12,240 points
14 views

1 answer to this question.

0 votes
Standard SQL-92 is represented by >; its inverse is!=. Both test for values, which NULL is not because it just serves as a placeholder to indicate the lack of a value. Because of this, the only valid predicates in these circumstances are IS NULL and IS NOT NULL. It is not just SQL Server that exhibits this behavior. All SQL dialects that adhere to standards function in the same way.

Note: You use IS NOT NULL to compare if your value is not null, whereas you use > 'YOUR VALUE' to compare if your value is not null. I can state if my value is NULL or NOT NULL but not if my value equals NULL or not. If my value is anything other than NULL, I can compare.
answered Sep 18 by narikkadan
• 20,880 points

Related Questions In Database

0 votes
1 answer

Can someone tell me what is IS NULL operator

Since it is not possible to test ...READ MORE

answered Nov 20, 2018 in Database by DataKing99
• 8,240 points
202 views
0 votes
1 answer

What is the NOT Operator in MySQL?

NOT operator displays a record when the ...READ MORE

answered Dec 14, 2018 in Database by Sahiti
• 6,380 points
409 views
0 votes
1 answer

Should I use != or <> for not equal in T-SQL?

Most of the existing databases support != Databases that ...READ MORE

answered Feb 14 in Database by Vaani
• 7,020 points
61 views
0 votes
0 answers

Check Excel file format from PowerScript not relying on file extension

We have a number of Excel files ...READ MORE

Mar 31 in Database by Edureka
• 13,640 points
30 views
0 votes
1 answer

How do I UPDATE from a SELECT in SQL Server?

MERGE INTO YourTable T USING ...READ MORE

answered Feb 3 in Database by Vaani
• 7,020 points
121 views
0 votes
0 answers

How do I UPDATE from a SELECT in SQL Server?

INSERT INTO Table (col1, col2, col3) SELECT col1, ...READ MORE

Feb 4 in Database by Vaani
• 7,020 points
45 views
0 votes
1 answer

What is a stored procedure?

A stored procedure is a set of ...READ MORE

answered Feb 4 in Database by Neha
• 8,920 points
216 views
0 votes
1 answer

LEFT JOIN vs. LEFT OUTER JOIN in SQL Server

At the top level there are mainly ...READ MORE

answered Feb 4 in Database by Neha
• 8,920 points
149 views
0 votes
1 answer

Login failed for user 'sa'. The user is not associated with a trusted SQL Server connection. (Microsoft SQL Server, Error: 18452) in sql 2008

Solution Go to Start > Programs > Microsoft SQL Server > Enterprise Manager. Right-click the SQL ...READ MORE

answered Sep 12 in Database by narikkadan
• 20,880 points
39 views
0 votes
1 answer

How do I create a table based on another table

Although CREATE TABLE AS... SELECT does exist ...READ MORE

answered Sep 12 in Database by narikkadan
• 20,880 points
30 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP