更新列值为空的表中所有行的列值?

时间:2022-06-13 13:02:53

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.

还在学习SQL-Fu,并尝试弄清楚如何在我的表(例如[TABLE1])上进行简单更新,将[COST]列值为NULL的所有行更新为[COST]值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.

谁能告诉我这是如何做得好的?我已经找到了如何更新列的每个行值的示例,但还没有完全能够以功能方式拼凑WHERE条件。

1 个解决方案

#1


10  

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

您可以使用IS NULL在列中测试NULL值。

UPDATE Table1
    SET cost = 0
    WHERE cost IS NULL;

#1


10  

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

您可以使用IS NULL在列中测试NULL值。

UPDATE Table1
    SET cost = 0
    WHERE cost IS NULL;