UPDATE query with JOIN
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: UPDATE query with JOIN

  1. #1
    Join Date
    May 2009

    Question UPDATE query with JOIN

    Suppose I am having following 2 tables

    Name Grade Sal
    ABC A
    PQR B
    XYZ C


    Grade Sal
    A 1000
    B 2000
    C 3000

    Now I want to update salary of employee having grade A.
    Simplest way is

    update emp_det e
    set sal =
    select g.sal from grade_det g
    where e.grade = g.grade
    and g.grade = 'A'
    where exists
    select g.sal from grade_det g
    where e.grade = g.grade
    and g.grade = 'A'

    But using "where exists" is very slow if my tables contains high volume of data.

    Is there any other way to do the same with fast execution?

  2. #2
    Join Date
    Mar 2007
    Ft. Lauderdale, FL
    homework, huh?
    No reason to use two inline views.
    Try again.
    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