Today I have seen one weird issue in PostgreSQL query. In which I have 2 tables Products and Parameters.
Purpose:
It's very simple query, I just want to list all products which are not there in parameter table.
Query:
select
id
from product_proudct
where active=True and
id not in
(
select distinct product_id from parameter_view
)
Issue:
It won't list anything if there is null value in parameter table in product_id column. I have verified by just removing null record from the parameter table by adding where clause.
select distinct product_id from parameter_view where product_id is not null
And then it's working fine but with null it won't work, it's really strange for me.
I would like to know the reason why subquery not working well with null ?