mercredi 27 mai 2015

Insert and select from other table and contant value

I'm looking to "mark" entries of my SQLite database. This following command will add new entries from the other_table:

INSERT OR IGNORE INTO landing_table (idx)
SELECT gidx FROM other_table

However, I want to update only the entries that don't exist in landing_table that do exist in other_table to have the value computed set to 1.

INSERT OR IGNORE INTO landing_table idx (idx, computed)
SELECT gidx FROM other_table
AND SET computed=1

Obviously this isn't correct. I would like to do this in a single insert statement rather than an insert and future UPDATE statement.

Aucun commentaire:

Enregistrer un commentaire