I wrote one sql query to get all records, but not specific ones.
My table is of column3type INTand may also have some null values. But the following queries ignore entries that have NULL in column3.
Table1:
ID | Column1 | Column2 | Column3
1 xyz xyz 200
2 xyz xyz 201
3 xyz xyz NULL
4 xyz xyz NULL
5 xyz xyz 201
SQL query:
SELECT
[ID],
[Column1], [Column2], [Column3] // (int, null)
FROM
[Table1]
WHERE
Column3 != 201
LINQ query:
from tb in _entities.Table1
where tb.Column3 != 201
Since two NULLs cannot be equal ie NULL = NULLalways False. Why do the above queries exclude entries with null values. Only the first record is returned.
source
share