How to change null field to return nothing?

3

In a query has many fields unfilled, I would like to change the null being printed so that nothing appears in the print.

    
asked by anonymous 18.05.2016 / 21:41

1 answer

8

Use the COALESCE function:

COALESCE(coluna, '')

The result of this function is the first of the two non-null arguments, so if the first one is not, get the value of the column, otherwise get the string empty. This can be used in any part of the query.

Example:

SELECT nome, COALESCE(endereco, '') AS endereco FROM tabela
    
18.05.2016 / 21:44