jeudi 6 octobre 2016

How to use IF condition in select query to display a column that is not null

I want to display a column in a select query according to the following :

1- If result is not null, display the column.

2- If the result is null, do not display the column.

I tried this but it doesn't work, it displays all the time the column (null or not null)

select 
 if(surname  is null,'',surname) as surname
from my_table

Aucun commentaire:

Enregistrer un commentaire