Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not equal to string value not working on postgreSQL

Tags:

postgresql

I've written a very simple query

select *, "Status" from "ABC" WHERE "ABCId" = 7; // Got 100 rows

ABC table has some columns one of them is "Status" with null value usually appearing as (Null)

When I try these queries

-- 1
select * FROM "ABC" where "ABCId" = 7 AND "Status" <> 'success'

-- 2
select * FROM "ABC" where "ABCId" = 7 AND "Status" != 'success'

-- 3
select * FROM "ABC" where "ABCId" = 7 AND "Status" NOT ILIKE '%success%'

I'm not getting any rows, I bang my head, this is a simple query :/

like image 589
Arjun Avatar asked Sep 03 '25 14:09

Arjun


1 Answers

You can use the null safe comparison operator is distinct from:

and "Status" is distinct from 'success'

that will be true for null values as well.