[mysql] 무한 스크롤 중복제거

SELECT id, file_name
FROM file
WHERE file_name > ${lastCursorFileName}
    OR (file_name = ${lastCursorFileName} AND id > ${lastCursorId})
ORDER BY file_name ASC, id ASC
LIMIT 2
SELECT id, file_name
FROM file
WHERE file_name > 'A'
    OR (file_name = 'A' AND id > 2)
ORDER BY file_name ASC, id ASC
LIMIT 2

출처 : https://namjug-kim.github.io/2019/02/15/mysql-paging-qeury.html

 

댓글 남기기