客户端发送间隔[6,11],我需要在执行此查询后从结果值中提取第6,第7,...第10和第11个值:
SELECT * FROM `projects` ORDER BY id DESC
客户也可以要求[12,17],[18,23]等
我是SQL新手,有人可以帮忙吗?网络对我没什么帮助。
修改
CREATE TABLE IF NOT EXISTS `projects` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(250) NOT NULL,
`category` int(10) NOT NULL,
`address` varchar(300) NOT NULL,
`long_description` text NOT NULL,
`thumb` text NOT NULL,
`short_description` varchar(1024) NOT NULL,
PRIMARY KEY (`id`)
答案 0 :(得分:2)
SELECT *
FROM `projects`
ORDER BY id DESC
LIMIT $offset,$amount
所以对于[6,11]
SELECT *
FROM `projects`
ORDER BY id DESC
LIMIT 6,6