Select column value if not null else use another column value

Viewed 27449

I have 2 columns in mysql table: a and b. a is allways string value and b is sometimes a string value and sometimes it is null.

How to construct a mysql SELECT so that the b would be taken if it is not null and a would be taken otherwise.

I tried to make some magic with concat and if...then with no success...

UPDATE - To extend my question, is there a function that would work like Ifnull but would work for null AND empty values?

3 Answers
Related