在MariaDB数据库中,SELECT语句与LIMIT子句一起使用可从表中检索一个或多个记录。
语法:
SELECT expressions FROM tables [WHERE conditions] [ORDER BY expression [ ASC | DESC ]] LIMIT row_count;
示例1: 以降序(desc)检索记录:
让无涯教程在"Students"表中将SELECT语句与LIMIT子句一起使用。结果以降序显示,LIMIT为4。
SELECT student_id, student_name, student_address FROM Students WHERE student_id <= 7 ORDER BY student_id DESC LIMIT 4;
输出:
链接:https://www.learnfk.comhttps://www.learnfk.com/mariadb/mariadb-select-limit.html
来源:LearnFk无涯教程网
示例2: 按升序(asc)检索记录:
SELECT student_id, student_name, student_address FROM Students WHERE student_id <= 7 ORDER BY student_id ASC LIMIT 4;
输出:
链接:https://www.learnfk.comhttps://www.learnfk.com/mariadb/mariadb-select-limit.html
来源:LearnFk无涯教程网
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)