Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compare nulll value with non null value SQL

I have two columns as below:

Column A Column B
A1 NULL
A1 A1
B1 C1.

When I query these columns as below:

SELECT Column A, Column B
from table
where Column A != Column B

I am expecting the following result:

Column A Column B
A1 NULL
B1. C1

But my query is only giving me the second line of the expected result.

like image 368
PHegde Avatar asked Jul 31 '26 08:07

PHegde


1 Answers

Consider below

select *
from your_table
where columnA is distinct from columnB    

with output

enter image description here

like image 56
Mikhail Berlyant Avatar answered Aug 01 '26 23:08

Mikhail Berlyant