SQL OFFSET 是一個(gè)用于限制查詢(xún)結(jié)果集的子句,通常與 LIMIT 或 FETCH 子句一起使用
SELECT * FROM table_name
LIMIT offset, row_count;
SELECT * FROM table_name
LIMIT row_count OFFSET offset;
SELECT * FROM table_name
ORDER BY column_name
OFFSET offset ROWS
FETCH NEXT row_count ROWS ONLY;
SELECT * FROM (
SELECT table_name.*, ROWNUM AS row_num
FROM table_name
)
WHERE row_num > offset AND row_num <= offset + row_count;
請(qǐng)注意,不同數(shù)據(jù)庫(kù)可能有不同的語(yǔ)法和性能特點(diǎn)。在實(shí)際應(yīng)用中,請(qǐng)根據(jù)您所使用的數(shù)據(jù)庫(kù)類(lèi)型選擇合適的語(yǔ)法。