一、过滤(WHERE)
1、字符和日期
字符:Select FIRST_NAMT from employees where FIRST_NAMT=’Neena’
日期:Select HIRE_DATE from employees where HIRE_DATE =’7-6月-1994’
2、比较运算
=、>、>=、<、<=、<>:Select salary from employees where salary>10000
使用 BETWEEN 运算来显示在一个区间内的值
BETWEEN...AND...: Select salary from employees where salary between 2000 and 3000
使用 IN运算显示列表中的值
IN(set): Select salary from employees where salary in(2000,3000,4000)
使用 IN运算显示列表中的值,使用 IN运算显示列表中的值,% 代表零个或多个字符(任意个字符),_ 代表一个字符
LIKE: Select salary from employees where salary like ’_0%’
使用 IS (NOT) NULL 判断空值
IS NULL: Select salary from employees where salary IS NULL
3、逻辑运算
AND 要求并的关系为真
Select salary , EMPLOYEE_ID from employees where salary > 5000 AND EMPLOYEE_ID>110
OR 要求或关系为真
Select salary ,EMPLOYEE_ID from employees where salary > 5000 OR EMPLOYEE_ID>110
NOT就是不把括号里的子符查询出来
Select salary from employees where salary Not in (8000)
二、排序(ORDER BY)
1、升序:Select salary,EMPLOYEE_ID from employees ORDER BY salary ASC(不加上ASC也是默认为升序的)
2、降序: Select salary,EMPLOYEE_ID from employees ORDER BY salary DESC
3、按别名排序(就是在查询结果里EMPLOYEE_ID会被A代替)
Select salary,EMPLOYEE_ID A from employees ORDER BY A
4、多个列排序(在以last_name排序的前提下再以salary排序)
Select last_name ,salary,EMPLOYEE_ID from employees ORDER BY last_name, salary