首页 小组 文章 相册 留言本 用户 搜索 我的社区 在线学堂 商城 购物车 支付钱包

[分享]软件6班_排序与分页

2024-04-02 10:29:05
0
222

SELECT * from employees;

SELECT employee_id,last_name,salary
from employees;

-- 只用order by的话,默认是升序
SELECT employee_id,last_name,salary
from employees ORDER BY salary;

-- DESC 降序
SELECT employee_id,last_name,salary
from employees ORDER BY salary DESC;

-- ASC 升序
SELECT employee_id,last_name,salary
from employees ORDER BY salary ASC;

-- 关于列的别名

SELECT employee_id,salary*12 year_salary
from employees;

-- 列别名用where不行
SELECT employee_id,salary*12 year_salary
from employees WHERE year_salary > 57600;

-- 列别名用order by可以

SELECT employee_id,salary*12 year_salary
from employees ORDER BY year_salary ASC;

SELECT employee_id,salary year_salary
FROM employees
where year_salary > 120
ORDER BY employee_id ASC;

SELECT employee_id,last_name,salary,department_id
from employees
ORDER BY department_id,salary;

SELECT employee_id,last_name,department_id
from employees;

SELECT employee_id,last_name,department_id
from employees LIMIT 0,10;

SELECT employee_id,last_name,department_id
from employees LIMIT 10;




SELECT employee_id,last_name,department_id
from employees LIMIT 0,15;

SELECT employee_id,last_name,department_id
from employees LIMIT 4,10;

-- 第11条到第20条

SELECT employee_id,last_name,department_id
from employees LIMIT 10,10;

SELECT employee_id,last_name,department_id
from employees LIMIT 4,10;

SELECT employee_id,last_name,department_id
from employees LIMIT 10 OFFSET 4;



(2-1)*10,10


(3-1)*10,10

评论
意见反馈