文件名称:用多列子查询进行修改-SQL语言基础
文件大小:5.26MB
文件格式:PPT
更新时间:2024-05-15 13:25:05
SQL 基础
用多列子查询进行修改 * SQL> UPDATE emp 2 SET (job, deptno) = 3 (SELECT job, deptno 4 FROM emp 5 WHERE empno = 7499) 6 WHERE empno = 7698; 1 row updated. 更改第 7698号雇员的工作和部门,以与第 7499号雇员进行匹配. * UPDATE emp SET (job, deptno) = (SELECT job, deptno FROM emp WHERE empno = 7499) WHERE empno = 7698; Updating Rows with a Multiple-Column Subquery Multiple-column subqueries can be implemented in the SET clause of an UPDATE statement. Syntax Instructor Note It may be worth showing participants that the results would be the same for the example on the slide if two different subqueries were used in the SET clause as illustrated below: SQL> UPDATE emp 2 SET job = (SELECT job FROM emp 3 WHERE empno = 7499), 4 deptno = (SELECT deptno FROM dept 5 WHERE dname = 'SALES') 6 WHERE empno = 7698; UPDATE table SET (column, column, ...) = (SELECT column, column, ... FROM table WHERE condition) WHERE condition;