-4

毎日変更される一連のフィールドを含むテーブルがあります (新しいフィールドが追加されるか、古いフィールドが削除されます)。主キー以外のすべてのフィールドを NULL に更新する方法を知る必要があります。これが私のテーブルの例です。

id = Primary Key
Field1, Field2, Field3, Field4, Field5

主キーを除くすべてのフィールドのデフォルト値は NULL です。特定のレコードに対してのみこれを行う必要があります。そのため、テーブル定義を変更しても機能しません。

Update table set <all fields except id> = NULL where id=12
4

2 に答える 2

1
update your_table
set field1 = null, field2 = null, field3 = null
where id = 123
于 2013-04-29T20:55:20.377 に答える
1
update yourTable
set field1 = null, field2 = null, ... -- Every field you need
where ... -- The conditions that define which records you are going to update
于 2013-04-29T20:56:15.393 に答える