SQL Problem #5
 Update statement using inner join

I have two tables TBUSERDTL TL and
SEQUENCENOUPDATE SU. I need to updat...
The following update statement works fine in SQL Server:


UPDATE TBUSERDTL TL
   SET SEQUENCE= SU.SEQUENCE_NU
   FROM TAB...
How do I rewrite in Oracle
Solution 1:
update tbuserdtl
set sequence_nu =(select sequence_nu
                      from se...
Improve Performance
Solution 2:
update tbuserdtl tl
set sequence_nu =(select su.sequence_nu
                       from se...
Upcoming SlideShare
Loading in …5
×

Sql Question #5

475 views

Published on

Update statement using inner join

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Sql Question #5

  1. 1. SQL Problem #5 Update statement using inner join I have two tables TBUSERDTL TL and SEQUENCENOUPDATE SU. I need to update the TL.sequence_nu to the SU.sequence_nu. The TL.eid is currently same as SU.eid so I am joining on this column.
  2. 2. The following update statement works fine in SQL Server: UPDATE TBUSERDTL TL SET SEQUENCE= SU.SEQUENCE_NU FROM TABLE TBUSERDTL INNER JOIN SEQUENCENOUPDATE SU ON EID = SU.EID THIS WILL NOT WORK IN ORACLE.
  3. 3. How do I rewrite in Oracle Solution 1: update tbuserdtl set sequence_nu =(select sequence_nu from sequencenoupdate su where tbuserdtl.eid = su.eid) where eid in (select eid from sequencenoupdate) Tbuserdtl and Sequencenoupdate. Updating sequence no in detail table from the sequencenoupdate table where eid matched.
  4. 4. Improve Performance Solution 2: update tbuserdtl tl set sequence_nu =(select su.sequence_nu from sequencenoupdate su where tbuserdtl.eid = su.eid) where exists (select * from sequencenoupdate su where su.eid = tl.eid)

×