all groups > sql server programming > december 2005 >
You're in the

sql server programming

group:

UPDATE using JOIN?



UPDATE using JOIN? Mike
12/6/2005 11:51:02 PM
sql server programming: I have a 2 tables (emp & NoBonus). I would like to update the bonus column of
emp (SET bonus = 5000) such that emp.empid <> Nobonus.empID, how can I do
this?
Basically, all empId's listed under NoBonus should not be updated


emp
----
empid
empName
dept
bonus

NOBonus
----------
Re: UPDATE using JOIN? amish
12/7/2005 12:06:50 AM
update emp set bonus = 5000 from emp inner join nobonus on emp.empid
<> nobonus.empid

Regards
Re: UPDATE using JOIN? MC
12/7/2005 9:12:03 AM
This is one way of doing it:

update emp
set bonus = 5000
from
emp
left join nobonus on emp.empID = nobonus.empID
where
nobonus.empID is null



MC


[quoted text, click to view]

AddThis Social Bookmark Button