Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: UPDATE query problem
sybrandb_at_hccnet.nl schrieb:
> On Fri, 29 Jun 2007 22:04:57 -0400, "Syltrem"
> <syltremzulu_at_videotron.ca> wrote:
>
>> Update MYTABLE >> set DESCRIPTION = (select DESCRIPTION from MYTABLE where >> MYTABLE.KEYVAL=(select XREF.KEYVAL2 from XREF where >> XREF.KEYVAL1=MYTABLE.KEYVAL)), >> set HELPTEST = (select HELPTEXT from MYTABLE where MYTABLE.KEYVAL=(select >> XREF.KEYVAL2 from XREF where XREF.KEYVAL1=MYTABLE.KEYVAL)) >> where MYTABLE.KEYVAL=XREF.KEYVAL1 >> >> (something like this I think, I would have to find good alias names to get >> it to work) >> >> What if I had 20 columns to update like this, I need to have 20 subqueries, >> each reading the exact same row? Is there a more efficient way of doing >> this?
... = (select description,helptext ... and
... in (select xref.keyval2 ...
But maybe my definition of "subquery" differs from your's.
For correct reults, try:
update mytable a
set (a.description, a.helptext) = (select b.description, b.helptext
from mytable b, xref where b.keyval = xref.keyval2 and xref.keyval1 = a.keyval);
Urs Metzger Received on Sat Jun 30 2007 - 09:31:54 CDT