Skip to content
Advertisement

SQL insert choice of column name dependant on select value

Hope the title is a reasonable description.

I have 2 tables in a db (sqlite).

files.fsno ranges from 2 to 5.

I am doing:

Then:

Is there a way to replace these 4 updates with something in the INSERT OR IGNORE? Something like:

The DB is Sqlite.

TIA, Pete

Advertisement

Answer

You can use a case expression:

This assumes that that sha256 are not duplicated in the table — that is, that you only want the new records to change.

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