📅  最后修改于: 2020-11-29 05:32:38             🧑  作者: Mango
在MariaDB数据库中,SELECT语句与LIMIT子句一起使用可从表中检索一个或多个记录。
句法:
SELECT expressions
FROM tables
[WHERE conditions]
[ORDER BY expression [ ASC | DESC ]]
LIMIT row_count;
范例1:
以降序检索记录:
让我们在“学生”表中将SELECT语句与LIMIT子句一起使用。结果以降序显示,LIMIT为4。
SELECT student_id, student_name, student_address
FROM Students
WHERE student_id <= 7
ORDER BY student_id DESC
LIMIT 4;
输出:
范例2:
以升序检索记录:
SELECT student_id, student_name, student_address
FROM Students
WHERE student_id <= 7
ORDER BY student_id ASC
LIMIT 4;
输出: