<> operator in SQL
sql, sql-server-2012
Solution
select * from table
where COALESCE(IsDeleted, 0) <> 1
-- or ISNULL instead of COALESCE.
--ISNULL seems to be better in subqueries, but it's not ANSI SQL.
or
select * from table
where IsDeleted <> 1 or IsDeleted IS NULL
Problem
I have a table like this ``` ID Name IsDeleted 1 Yogesh Null 2 Goldy 1 ``` Now when I run this query ``` select * from tableName where IsDeleted <> 1 ``` I should get `ID 1` record, But I am not getting it, But when I run this ``` select * from tableName where IsDeleted is null ``` I get `ID 1` record, Why am I facing this behavior ?? Isn't `NULL <> 1` is a true statement in SQL ?? `IsDeleted` is a `bit` type field with `Allow Null true`