Update statement with inner join
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: Update statement with inner join

  1. #1
    Join Date
    Oct 2009
    Posts
    1

    Unhappy Update statement with inner join

    Can someone help me rewrite this pseudo code into ansi sql syntax?

    We have 3tables:
    TABP
    ---
    a
    b

    TABQ
    ---
    b
    c
    d

    TABR
    ---
    a
    c
    d


    Update TABR R set R.d =
    (
    select Q.d from TABQ Q, TABP P
    where Q.b=P.b
    and R.a=P.a
    )
    where R.d=-1

    I tried but the explain showed nested loops and is running too long
    Thanks
    sri

  2. #2
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,554
    There is an inline view so you should expect to see nested loops - one execution of the inline view per row in TABR.

    What kind of indexes do you have to serve this statement?
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width