关联表的批量更新(ORACLE/SQLSERVER/MySQL)
在SQL SERVER中,关联表的批量更新,可以参看这里:
http://www.cnblogs.com/downmoon/archive/2007/12/29/1019832.html
Oracle下没找到好的语法,临时用这个:
update employee set hrdeptname= (select d.DEPTNAME from DEPARTMENT d where ROWNUM=1 and d.deptID=employee.hrdeptID )
对应的SQL Server语法:
Update employee set hrdeptname=d.DEPTNAME from DEPARTMENT d inner join employee e on e.HRDEPTID=d.DEPTID where 1=1;
对应的mysql语法:
update employee t,department d set t.hrdeptname =d.DEPTNAME where v.HRDEPTID=t.DEPTID;