This article is half-done without your Comment! *** Please share your thoughts via Comment ***
If you are a SQL Database Developer, you might be writing some condition like WHERE 1=1 or WHERE 1=2.
Here, I simply modified it and instead of WHERE 1=1 what do you think about WHERE NULL=NULL.
Last year, I asked this question and most of the developers were confused. Actually, NULL = NULL returns nothing because NULL is not a real value.
Check the below demonstration:
Create a table:
1 2 3 4 5 |
CREATE TABLE tbl_Employee (EmpID INT, EmpName VARCHAR(10), DOB DATE) INSERT INTO tbl_Employee VALUES (1,'Anvesh','19880126'),(2,'Jenny','19910409'),(3,'Alpesh','19930610') ,(4,'Roy','19910214'),(5,'Manish','19850505'),(6,'Nupur','19880808') |
Returns all records:
1 2 |
SELECT * FROM tbl_Employee WHERE 1=1 |
Returns nothing:
1 2 |
SELECT * FROM tbl_Employee WHERE NULL=NULL |
Leave a Reply