August 4, 2005 at 2:31 pm
UPDATE p
SET p.name=m.name
FROM
tabl a INNER JOIN tab2 M ON p.number=m.number
How can i write equivalnet of the above sql server update statement in oracle.
thanks.
August 4, 2005 at 2:59 pm
Are you working with 3 tables aliased as p, a, and m? I don't understand what tabl a is for.
If that was a typo and you're really dealing with only 2 tables, this should work in Oracle:
UPDATE p
SET p.name = (SELECT m.name
FROM tab2 m
WHERE m.number = p.number);
Greg
Greg
August 4, 2005 at 11:19 pm
Depending on the version of Oracle, you might have to use:
UPDATE p
SET p.name=m.name
FROM tabl p , tab2 m
WHERE p.number = m.number
Andy
August 7, 2005 at 4:19 pm
Please tell me what version of Oracle has a FROM clause for UPDATEs?
--Jeff Moden
Change is inevitable... Change for the better is not.
August 8, 2005 at 2:09 am
You should avoid "UPDATE p SET p.name = (SELECT m.name FROM tab2 m WHERE m.number = p.number);" since it will update SOME p.name to NULL: the ones for which there is no correspondent in tab2.
Try "update (SELECT p.number, p.name m.name FROM p, m WHERE m.number = p.number) set p.name = SELECT m.name"
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply