xCloudx8 xCloudx8 - 3 months ago 7
SQL Question

SQL avoid empty rows

Is there a way to avoid empty rows in a SQL statement?
My output is:

a | b | c
1 2 3
4
EMPTY EMPTY EMPTY
5


But i want:

a | b | c
1 2 3
4
5

Answer

If the value is empty or if it is null are two different things so I am unsure which you are looking for.

If NULL

SELECT * FROM table WHERE a IS NOT NULL OR b IS NOT NULL OR c IS NOT NULL;

If empty

SELECT * FROM table WHERE a <> '' OR b <> '' OR c <> '';
Comments