Reputation: 13
I'm running a report using SELECT and want to change all NULL values within a column to a specific value in the output. All non-null values should remain untouched.
The null values exist because of an outer join. The column does not exist in all tables, but in the output I want a single value to appear instead of NULL.
Here is non-working SQL to illustrate what I am trying to do.
SELECT number, letter IF number = null THEN 0 END IF FROM... and so on.
Upvotes: 1
Views: 39
Reputation: 1866
SELECT letter , IF(number is null, 0, number) as number FROM .....
Upvotes: 0
Reputation: 1254
Something like this:
SELECT number, letter, ifnull(number,0)
FROM table
Upvotes: 1