从 MySQL 查询返回第 n 条记录 [英] Return the nth record from MySQL query

查看:31
本文介绍了从 MySQL 查询返回第 n 条记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望从 MySQL 查询中返回第 2、3 或 4 条记录(基于按 ID 升序的查询)

I am looking to return the 2nd, or 3rd, or 4th record from a MySQL query (based on a query by ID ascending)

问题是,我不知道 ID,只知道它是查询中的第三行.

The problem being, I won't know the ID, only that it is the 3rd row in the query.

推荐答案

SELECT * FROM table ORDER BY ID LIMIT n-1,1

它说返回一个从记录 n 开始的记录.

It says return one record starting at record n.

这篇关于从 MySQL 查询返回第 n 条记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆