Sql Question #5
Upcoming SlideShare
Loading in...5
×
 

Sql Question #5

on

  • 449 views

Update statement using inner join

Update statement using inner join

Statistics

Views

Total Views
449
Views on SlideShare
449
Embed Views
0

Actions

Likes
0
Downloads
2
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Sql Question #5 Sql Question #5 Presentation Transcript

    • 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.
    • 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.
    • 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.
    • 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)