Robin Rodricks
Robin Rodricks

Reputation: 114126

SQL to delete the value from a column where both columns exist

Is this correct? Will it work with Sqlite as well?

 UPDATE table SET oldCol=NULL WHERE (oldCol!=NULL AND newCol!=NULL)

Upvotes: 0

Views: 44

Answers (2)

Mowgli
Mowgli

Reputation: 129

you can use this also. UPDATE table SET oldCol=NULL WHERE (oldCol is not NULL AND newCol is not NULL)

Upvotes: -1

potashin
potashin

Reputation: 44601

No, you should use is not null:

update tbl set oldcol = null where oldcol is not null and newcol is not null

Upvotes: 3

Related Questions