mssqlserver查询方法
其实我做了最简的就是如下写法
| 代码如下 | 复制代码 |
|
上一条记录的SQL语句: select top 1 * from news where newsid 下一条记录的SQL语句: select top 1 * from news where newsid>id order by newsid ASC |
|
另一种写未能
id是指当前数据news_id参数
方法一:
| 代码如下 | 复制代码 |
|
string nextSql = "select top 1 * from news where news_id > " + id + " order by news_id ASC" |
|
方法二:
| 代码如下 | 复制代码 |
|
|
|
mysql查询上一条与下一条的办法
如果ID是主键或者有索引,可以直接查找:
方法1:
| 代码如下 | 复制代码 |
| 1.select * from table_a where id = (select id from table_a where id < {$id} order by id desc limit 1); 2.select * from table_a where id = (select id from table_a where id > {$id} order by id asc limit 1); |
|
方法2:
| 代码如下 | 复制代码 |
| 1.select * from table_a where id = (select max(id) from table_a where id < {$id}); 2.select * from table_a where id = (select min(id) from table_a where id > {$id}); |
|
其他更优的暂时还没想出来
韩剧再婚皇后阿里云盘全集高清1080P资源链接-韩剧再婚皇后免费阿里云盘资源下载4K高清无删减版链接
poipiku网站如何打开-poipiku官网网页版访问入口
明日方舟:终末地-云游戏畅玩入口-明日方舟:终末地-网页版在线直连地址
poki在线小游戏网页版-poki免费游戏大全入口
poki游戏入口-点开即玩-poki游戏-在线免费畅玩
原神akt大佬资源viciNeko入口链接-原神akt大佬资源网页vicineko入口链接分享