使用IN操作符-SQL语言基础

时间:2021-04-25 19:38:10
【文件属性】:
文件名称:使用IN操作符-SQL语言基础
文件大小:5.26MB
文件格式:PPT
更新时间:2021-04-25 19:38:10
SQL 基础 使用IN操作符 * SQL> SELECT empno, ename, sal, mgr 2 FROM emp 3 WHERE mgr IN (7902, 7566, 7788); EMPNO ENAME SAL MGR --------- ---------- --------- --------- 7902 FORD 3000 7566 7369 SMITH 800 7902 7788 SCOTT 3000 7566 7876 ADAMS 1100 7788 用IN操作符来检验一个值是否在一个列表中. * SELECT empno, ename, sal, mgr FROM emp WHERE mgr IN (7902, 7566, 7788); The IN Operator To test for values in a specified list, use the IN operator. The slide example displays employee number, name, salary, and manager’s employee number of all the employees whose manager’s employee number is 7902, 7566, or 7788. The IN operator can be used with any datatype. The following example returns a row from the EMP table for any employee whose name is included in the list of names in the WHERE clause: SQL> SELECT empno, ename, mgr, deptno 2 FROM emp 3 WHERE ename IN ('FORD' , 'ALLEN'); If characters or dates are used in the list, they must be enclosed in single quotation marks (''). Instructor Note Explain that the IN ( … ) is actually translated by Oracle server to a set of OR conditions (a = value1 OR a = value2 OR a = value3 ). So using IN ( … ) has no performance benefits and can be used for logical simplicity. Demo: l2in.sql Purpose: To illustrate using the IN operator.

网友评论