sql分页

mysql:
SELECT ... FROM ... WHERE ... ORDER BY ... LIMIT ...
SELECT * FROM articles WHERE category_id = 123 ORDER BY id LIMIT 50, 10

SELECT * FROM articles WHERE category_id = 123 AND id >= (
SELECT id FROM articles ORDER BY id LIMIT 10000, 1
) LIMIT 10(如果id不完整、不连贯的话有问题)


oracle:
select * from employees a,(select employee_id,rownum r from employees)e where a.employee_id=e.employee_id and r  between 5 and 7;

select * from (select a.* ,rownum r from employees a where rownum<=7) where r>=5

你可能感兴趣的:(sql)