bilal_izloo
bilal_izloo

Reputation: 37

Data Comparing in Sql

I am a front end developer in .net i have a question about the data comparison in SQ L whether it compares by value or by reference.

SELECT 1 WHERE NULL =NULL --> No Result

SELECT 1 WHERE 1=1 --> Return the result 1.

Thanks in Advance.

Upvotes: 0

Views: 83

Answers (1)

newfurniturey
newfurniturey

Reputation: 38436

The comparison is done by value, but I think where you're getting confused is with NULL values which really mean "a missing value".

To compare against NULL, you'll want to use col_name IS NULL or col_name IS NOT NULL instead of the standard = or != operators.

For MySQL, refer to the Working with NULL Values documentation. T-SQL has less of a reference with IS [NOT] NULL

Upvotes: 1

Related Questions