update from select in same table

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Can some kind soul please help me turn this into sql

SET rowA.colA = rowB.colB
WHERE rowA.colC = rowB.colD

Re: update from select in same table

BoxRec wrote:
Quoted text here. Click to load it

This is one of those uses for the MySQL syntax extension for multi-table
UPDATE operations.  It isn't standard SQL, but I think the following
will do what you want (NB: I haven't tested this):

UPDATE rowA SET rowA.colA = rowB.colB
FROM TableA AS rowA, TableA AS rowB
WHERE rowA.colC = rowB.colD

Note that you must use the table alias right after UPDATE, not the real
name of the table.

Bill K.

Site Timeline