有没有哪种sql语句能获取到某条件下的上一条跟下一条数据
时间:2011-08-26
来源:互联网
例如,select * from table where id=xxx order by vnums desc
id 作品id(主键,唯一) vnums 浏览数(有可能相同)
假如给出 id=50 求它的上一条跟下一条数据
id 作品id(主键,唯一) vnums 浏览数(有可能相同)
假如给出 id=50 求它的上一条跟下一条数据
作者: z328769706 发布时间: 2011-08-26
下一条:
SQL code
上一条:
SQL code
SQL code
select * from table where id=(select min(id) from table where id>50)
上一条:
SQL code
select * from table where id=(select max(id) from table where id<50)
作者: jordan102 发布时间: 2011-08-26
select * from table where id>50 order by vnums limit 1
select * from table where id<50 order by vnums desc limit 1
select * from table where id<50 order by vnums desc limit 1
作者: moocky 发布时间: 2011-08-26
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28