DBAsupport.com Forums - Powered by vBulletin
Results 1 to 6 of 6

Thread: Important Query

  1. #1
    Join Date
    Jan 2014
    Posts
    2

    Important Query

    Hi

    plz send the solution to the query which is attached thru paint brush image
    Attached Images Attached Images

  2. #2
    Join Date
    Nov 2000
    Location
    Pittsburgh, PA
    Posts
    4,166
    Is that all you want? Or does your homework assignment require that you do the update with
    a single update statement? If you you need to look at the case statement.

    In the future you should really specify more detail when posting to the forum, or any forum.
    Also don't include the png file that your teacher sent you, actually type the data.

    Code:
    UPDATE emp
       SET salary = 7782
     WHERE emp_id = 7839;
    
    UPDATE emp
       SET emp_id = 5000
     WHERE salary = 7782;
    
    COMMIT;

  3. #3
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    so, you want to swap Clark's employee-id with King's salary?

    I apologize if column names are not correct but, poster missed that particular little piece of information.
    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.

  4. #4
    Join Date
    Nov 2000
    Location
    Pittsburgh, PA
    Posts
    4,166
    Quote Originally Posted by PAVB View Post
    so, you want to swap Clark's employee-id with King's salary?

    I apologize if column names are not correct but, poster missed that particular little piece of information.
    The table is directly from the scott sample schema. Even the data is from the default schema.
    Not a very useful request.

    http://www.orafaq.com/wiki/SCOTT

  5. #5
    Join Date
    Jan 2014
    Posts
    2

    Important query

    Quote Originally Posted by muba View Post
    Hi

    plz send the solution to the query which is attached thru paint brush image
    it need to be done using single update statement

  6. #6
    Join Date
    Nov 2000
    Location
    Pittsburgh, PA
    Posts
    4,166
    Quote Originally Posted by muba View Post
    it need to be done using single update statement
    You need something like this.

    Code:
    UPDATE mubas_emo_table
       SET salary = CASE emp_id
                    WHEN  7839 THEN 7782
                    ELSE salary
                    END,
           emp_id = CASE emp_id
                    WHEN  7782 THEN 5000
                    ELSE salary
     WHERE emp_id IN ( 7782, 7839 );
    Last edited by gandolf989; 01-06-2014 at 10:24 AM.

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