Skip to main content
2 of 4
Text formatting
Ergest Basha
  • 4.5k
  • 3
  • 7
  • 21

UPDATE & SELECT & INNER JOIN combined (SQL92) — How?

I have two tables with the following columns:

Table1
id 
Sort
dou

and

Table2
id_Table1
Sort

and I need to read all values of Table1.Sort where Table1.dou = 1 and write them into Table2.Sort, into those rows where Table2.id_Table1 matches the Table1.id values.

I can do: SELECT Sort FROM Table1 WHERE dou = 1

And I can do UPDATE Table2 SET Sort WHERE id_Table1 = 'uuid'

But how can I combine these in a way that all Table1.Sort values overwrite the Table2.Sort values?

Thanks a lot for any hint!