replace a column with another column when column is null in SELECT statement

Salar :

Here is my dummy Schema in MYSQL:
A column: which is a nullable string
B column: which is a string but its not null

enter image description here
I only want to select A columns but when facing a null, I want it to be replaced with the B column.
How can I do that?
this is my desired output
enter image description here

Gordon Linoff :

Use coalesce():

select coalesce(a, b) as a
from t;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=16515&siteId=1