[SQL] Update from same table

2004-02-04 Thread Jürgen Cappel
Hello, I want to update columns in a table that match a fixed key from the same column of the same table matching another fixed key. There can be several tuples per key distinguished by a secondary id. Tuples are unique with the combined keys. Maybe a query could look something like this:

Re: [SQL] Update from same table

2004-02-04 Thread Josh Berkus
Jurgen, UPDATE a.mytable from b.mytable SET a.mycolumn = b.mycolumn WHERE a.firstid = some_key AND b.firstid = some_other_key AND a.secondaryid = b.secondaryid; Very close, actually; you just need to fix the table alias: UPDATE mytable FROM