1

SQLite doesn't support updates with joins. (see this closely related SO question)

Let's say I have a table data with these columns:

INTEGER id
TEXT foo
TEXT bar
TEXT baz

and I have another table selection with one column INTEGER id.

What I would like to do is given an integer id srcID, to copy the foo and bar values from the data row src to the data rows where the ids match the selection table.

In "standard" SQL (or at least the MySQL variant), this is something like

UPDATE data, selection, data as src
  SET data.foo = src.foo, data.bar = src.bar
  WHERE data.id = selection.id
  AND src.id = ?

(? = prepared statement value set to srcID)

Any suggestions?

Community
  • 1
  • 1
Jason S
  • 184,598
  • 164
  • 608
  • 970

1 Answers1

0

Last time I used Oracle, I don't think it supported your syntax either.

I don't see how you could do that with a single SQL command in SQLite, but have you looked into using an UPDATE trigger on the data table?

Paul Lefebvre
  • 6,253
  • 3
  • 28
  • 36