Josef
Josef

Reputation: 2726

Select query - auto populate empty field

Is it possible to automatically populate empty or null field with sql query? For example i have have table with three columns; ID, Name, Letter.

When fetching data with SELECT ID, Name, Letter FROM table i want to fill column Letter with A if it is empty for certain record?

Upvotes: 0

Views: 1051

Answers (1)

juergen d
juergen d

Reputation: 204884

Use coalesce

SELECT ID, Name, coalesce(Letter, 'A') as Letter
FROM your_table

or IFNULL

SELECT ID, Name, ifnull(Letter, 'A') as Letter
FROM your_table

Upvotes: 4

Related Questions