-- 查询示例:从employees表中选择所有列
SELECT * FROM employees;
-- 查询示例:只选择特定的列(first_name, last_name, salary)
SELECT first_name, last_name, salary FROM employees;
-- 查询示例:使用别名
SELECT
first_name AS fname,
last_name AS lname,
salary AS salary
FROM employees;
-- 查询示例:去除重复行
SELECT DISTINCT department_id FROM employees;
-- 查询示例:条件查询(where)
SELECT * FROM employees WHERE department_id = 5;
-- 查询示例:排序(order by)
SELECT * FROM employees ORDER BY salary DESC;
-- 查询示例:限制结果数量(limit)
SELECT * FROM employees LIMIT 10;
-- 查询示例:分页结果(limit, offset)
SELECT * FROM employees LIMIT 10 OFFSET 20; -- 跳过前20条记录,然后返回10条
评论已关闭