Algorithmix
asked on
How to update a table based on the output of a select?
I need to update a table based on the output of a select.
Example:
Select a.fld1, a.fld2 from db.tableA a where a.fld3 = 'blahblah'
The output might be something like
fld1 fld2
'TEXT1' 123
'TEXT2' 432
'TEXT3' 534
etc..
I'd like to be able to update tableB based on the results of this select.
update db.tableB b set b.fld1 = a.fld1 where b.fld2 = a.fld2
how would write such an update command?
i hope i'm explaining myself clearly - ?
Example:
Select a.fld1, a.fld2 from db.tableA a where a.fld3 = 'blahblah'
The output might be something like
fld1 fld2
'TEXT1' 123
'TEXT2' 432
'TEXT3' 534
etc..
I'd like to be able to update tableB based on the results of this select.
update db.tableB b set b.fld1 = a.fld1 where b.fld2 = a.fld2
how would write such an update command?
i hope i'm explaining myself clearly - ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks guys!
... where b.fld2 in (select a.fld2 from tableA)
cheers!
Don