Reputation: 2485
I want to select displayname as username
if username =null and if username is NOT NULL then select username as username
eg.
id username displayname
1 xyz NULL
2 NULL abc
How can I do that in one single select statement...Thanks
Upvotes: 2
Views: 518
Reputation: 7879
coalesce(username, dispalyname) should help you.
E.g.:
select coalesce(username, dispalyname) from users
where ...
Upvotes: 5