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 t
Use IFNULL(b, a).
If expr1 is not NULL, IFNULL() returns expr1; otherwise it returns expr2.
This is a MySQL specific function. You can also use COALESCE in the same way. This will work in more databases but it has slightly worse performance in MySQL than IFNULL.