Skip to content
Advertisement

Update referencing on subquery (sqlite)

I have a table with md5 sums for files and use the following query to find the files which exist in one hashing-run and not in the other (oldt vs newt):

now i want to put a flag in an extra column with an update clause, like

and there i want a reference to the upper query as subquery, but i cannot find a proper way. Is there a possibility to use the results from the upper query for the where clause from the update-query? (I added now some Table Screenshots with simple Table Data)

Table Description Table Description

Table Data before UPDATE Table Data before UPDATE

desired Table Data after UPDATE desired Table Data after UPDATE

Advertisement

Answer

SQLite does not support aliasing the updated table.
In your case you don’t need that.
You can use the table’s name md5_sums inside the subquery since you aliased the table of the SELECT statement as newt.

See the demo.
Results:

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