Skip to content
Advertisement

Update SQLite row only if a column is empty

I have the following:

JavaScript

one and three should always be updated.

However, how can I update two only if it is null/empty?

I can do this in a separate command, though how can I achieve this in one prepared statement?

I am using SQLite3

Advertisement

Answer

Use a CASE expression for column two:

JavaScript

Or with COALESCE():

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement