语法:
UPDATE 表 SET 列名1 = 值 WHERE 列名N = 值
示例1
单字段+单表
UPDATE EMP SET SAL=SAL*(1+0.2) where DEPTNO='30';
示例2
多字段+单表
UPDATE EMP SET SAL=SAL*(1+0.2),comm=500 where DEPTNO='30';
示例3
单字段+多表查询
update EMP set deptname = (select dname from dept where dept.deptno=EMP.DEPTNO)
where EMP.DEPTNO ='30';
or
update EMP set deptname = (select dname from dept where dept.deptno=EMP.DEPTNO)
where EMP.DEPTNO in (select deptno from employee );
示例4
多字段+多表查询
update EMP set (deptname,deploc) = (select dname,loc from dept where dept.deptno=EMP.DEPTNO)
where EMP.DEPTNO ='30';