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}); |
|
其他更优的暂时还没想出来
deepin20怎么新增字体? deepin20安装字体的教程
Linux如何给文件权限? linux给文件添加可执行权限的技巧
deepin20桌面图标样式怎么修改? deepin更换图标主题的技巧
virtualbox打不开虚拟机怎么办? linux无法访问virtualbox的解决办法
deepin怎么注销系统? deepin系统注销与切换用户的方法
Manjaro linux怎么调鼠标速度? Manjaro鼠标设置光标速度的技巧