Home > Database > Mysql Tutorial > body text

MySQL查询前n条记录

WBOY
Release: 2016-06-07 17:27:58
Original
1249 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template