Home  >  Article  >  Database  >  MySQL查询前n条记录

MySQL查询前n条记录

WBOY
WBOYOriginal
2016-06-07 17:27:581204browse

SQL Server 中使用top查询前n行数据,语法规则为: SELECT TOP number|percent column_name(s) FROM table_name 而在MySQL中使用

SQL Server 中使用top查询前n行数据,语法规则为:

SELECT TOP number|percent column_name(s) FROM table_name

而在MySQL中使用的是limit:

SELECT column_name(s) FROM table_name LIMIT number 

例子:

SELECT * FROM keywordtable limit 0,4;

SELECT * FROM keywordtable limit 1,4;

在第一条语句中0可以省略,默认是从第一条开始。第二条语句查询 的是2、3、4条数据。

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn