Click here to Skip to main content
15,909,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have sql query…
See table employee or department.

table employee ={Empid,Mgrid,Name,Deptid}
table department = {Deptid,Hod,Location ,Phone}

I want to update department table. A mgrid{ somthing} whose under some employee and each employee have a department id . each employee department phone no to update with new phone no.
How to update this table..??
Posted
Updated 4-Oct-12 22:30pm
v2

try below query

SQL
update department
set phone = YourValue
from  department d
inner join  employee AS e ON d.deptid = e.deptid
where  YourCondition
 
Share this answer
 
SQL
UPDATE A
  SET A.Phoneno= 'XXXXXX'
FROM Department A, Employee B
WHERE A.deptId=B.deptId
and B.EmpId = 'E001'
 
Share this answer
 
SQL
Update d
Set phone = @newphoneNo
From department d join Employee e
on d.deptid = e.deptid
where employeeid = @empid
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900