Reputation: 694
In my user table, there's email and number fields. I have to select the email. But if it is null, select the number. Can I do this in one query?
Thanks.
Upvotes: 2
Views: 121
Reputation: 263703
you can use COALESCE
SELECT COALESCE(email, number)
FROM tableName
From Docs,
Returns the first non-NULL value in the list, or NULL if there are no non-NULL values.
Upvotes: 4