Update Subquery

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is it possible to run an update statement with a subquery? What is the syntax?

Say you have emp and dept tables.

update emp set emp.depdesc = select dept.description from dept where emp.deptno
= dept.deptno

In other words I want to put values in preexisting records based on another
table. If dept has a description, then I want emp to have fname, lname, deptno,
deptdescription.

Is that possible?




(e-mail address removed)
 
The proper syntax for
update emp set emp.depdesc = select dept.description from
dept where emp.deptno
= dept.deptno
is
UPDATE emp INNER JOIN dept ON emp.deptno = dept.deptno SET
emp.depdesc = dept.description

Hope This Helps
Gerald Stanley MCSD
 
Back
Top