SQL分页查询
-
二种sql分页查询语句分享
1. 使用LIMIT和OFFSET:SELECT * FROM table_name LIMIT page_size OFFSET (page_number - 1) * page_size;,2. 使用ROW_NUMBER()函数:WITH temp AS (SELECT *, ROW_NUMBER() OVER (ORDER BY id) AS row_num FROM table_name) SELECT * FROM temp WHERE row_num ˃= start_row AND row_num ˂= end_row;