Update Column value for all rows in Table where Column Value Is Null?
Asked Answered
D

1

5

Still learning SQL-Fu, and trying to figure out how to do a simple update on my Table (ex. [TABLE1])to where all rows that have a [COST] column value of NULL are updated to a [COST] value of 0.00.

Can anyone show me how this is properly done? I've found examples for how to update EVERY row value for the column, but haven't quite been able to piece together the WHERE condition in a functional way.

Dorey answered 17/12, 2015 at 15:49 Comment(1)
Possible duplicate of Update columns with Null valuesScudder
G
11

You can test for a NULL value in a column using IS NULL.

UPDATE Table1
    SET cost = 0
    WHERE cost IS NULL;
Germann answered 17/12, 2015 at 15:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.