Question: 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 as result.

Answer: 
Consider below

```
select *
from your_table
where columnA is distinct from columnB    

```

with output

[![enter image description here](https://i.stack.imgur.com/QtavW.png)](https://i.stack.imgur.com/QtavW.png)
```
SELECT * from Your_table where IFNULL(`Column A`, 'NULL') != IFNULL(`Column B`, 'NULL')

```

`IFNULL(expression, alt_value)` function returns the value of the `expression` if it's not `NULL` and returns `alt_value` when `expression` is `NULL`.
So, from the above query, `Column A` and `Column B` will have the string value of `'NULL'` when the column has the `NULL` value so they can still be comparable.