一,子查询
SELECT e.emp_id, e.fname, e.lname FROM (SELECT emp_id, fname, lname, start_date, title FROM employee ) e;
二,从视图中查询
CREATE VIEW employee_vw AS -> SELECT emp_id, fname, lname, -> YEAR(start_date) start_year -> FROM employee; SELECT emp_id, start_year -> FROM employee_vw;
三,联表查询
SELECT e.emp_id, e.fname, e.lname, d.name dept_name FROM employee AS e INNER JOIN department AS d ON e.dept_id = d.dept_id;
四,WHERE子句配逻辑表达式
SELECT emp_id, fname, lname, start_date, title FROM employee WHERE title = 'Head Teller' OR start_date > '2002-01-01';
五,GROUP BY子句配合HAVING使用
;
六,ORDER BY排序使用内置函数
) DESC;