文件名称:使用LIKE操作符-SQL语言基础
文件大小:5.26MB
文件格式:PPT
更新时间:2024-05-15 13:24:50
SQL 基础
使用LIKE操作符 * SQL> SELECT ename 2 FROM emp 3 WHERE ename LIKE 'S%'; 用LIKE进行某个字符串值的通配符匹配,来选出某些行. 查询条件中既可以包含字符,也可以包含数字. % 代表0个或者多个字符. _ 代表一个字符. * SELECT ename FROM emp WHERE ename LIKE 'S%'; The LIKE Operator You may not always know the exact value to search for. You can select rows that match a character pattern by using the LIKE operator. The character pattern-matching operation is referred to as a wildcard search. Two symbols can be used to construct the search string. The SELECT statement above returns the employee name from the EMP table for any employee whose name begins with an “S.” Note the uppercase “S.” Names beginning with an “s” will not be returned. The LIKE operator can be used as a shortcut for some BETWEEN comparisons. The following example displays names and hire dates of all employees who joined between January 1981 and December 1981: SQL> SELECT ename, hiredate 2 FROM emp 3 WHERE hiredate LIKE '%1981';