-
UPDATE query with JOIN
Suppose I am having following 2 tables
Emp_det
Name Grade Sal
ABC A
PQR B
XYZ C
and
Grade_det
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?
-
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|