views:

40

answers:

2

Can any one please let me know the best way to use IF statement in mysql query to show if the "email" field is NULL then it should show as "no email"...

Postcode    Telephone             Email
----------------------------------------------------------
BS20 0QN    1275373088         no email
BS20 0QN    1275373088         no email
PO9 4HG 023 92474208        [email protected]
SO43 7DS    07801 715200       [email protected]
----------------------------------------------------------
+5  A: 

Use the COALESCE function:

COALESCE(Email, 'no email')
Marcelo Cantos
+3  A: 

Try the IFNULL function:

SELECT Postcode, Telephone, IFNULL(Email, "no email")
FROM table
Gumbo