1.过滤:
SELECT *|{[DISTINCT] column|expression [alias],...}
FROM table
[WHERE condition(s)];
2.字符:
SELECT last_name, job_id, department_id FROM employees WHERE last_name = ‘Whalen‘;
3.比较运算符:
BETWEEN...AND...(在两个值之间 (包含边界))
SELECT last_name, salary FROM employees WHERE salary BETWEEN 2500 AND 3500;
IN(set) (等于值列表中的一个)
SELECT employee_id, last_name, salary, manager_id FROM employees WHERE manager_id IN (100, 101, 201);
LIKE(模糊查询)
SELECT first_name FROM employees WHERE first_name LIKE ‘S%‘;
IS NULL(空值)
SELECT last_name, manager_id
FROM employees
WHERE manager_id IS NULL;
4.逻辑运算:
AND(逻辑并)
SELECT employee_id, last_name, job_id, salary FROM employees WHERE salary >=10000 AND job_id LIKE ‘%MAN%‘;
OR(逻辑或)
SELECT employee_id, last_name, job_id, salary FROM employees WHERE salary >= 10000 OR job_id LIKE ‘%MAN%‘;
NOT(逻辑否)
SELECT last_name, job_id FROM emp WHERE job_id NOT IN (‘IT_PROG‘, ‘ST_CLERK‘, ‘SA_REP‘);
5.ORDER BY子句
使用 ORDER BY 子句排序 。
ASC: 升序
SELECT last_name, job_id, department_id, hire_date
FROM employees
ORDER BY hire_date ASC ;
DESC: 降序
SELECT last_name, job_id, department_id, hire_date
FROM employees
ORDER BY hire_date DESC ;
SELECT last_name, job_id, department_id, hire_date
FROM employees
ORDER BY hire_date ;
原文:http://www.cnblogs.com/adada/p/7241337.html