求一条sql语句,如何查找满足条件的下一条记录 如下表:id menu1 menu1 1 one 22 two 33 three 24 four 1查询条件是menu1=two要得到的结果是 id=3 menu1=three menu2=2请问谁知道这个怎么查询?谢谢。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select top 1 *from tablewhere id > (select id from table where menu1 = 'two') order by id asc select * from 表 where id =(select menu2 from 表 where menu1='two') Id 连续只要ID + 1 ,不连续就得> select * from table awhere exists (select 1 from table where id - a.id < 0 and menu1= 'two') select top 1 * from table awhere exists (select 1 from table where id - a.id < 0 and menu1= 'two') select top 1 * from table awhere exists (select * from table b where b.id < a.id and menul = 'two') 不好意思,后面列名应该是menu2 select * from id=(select min(id) where id>( select id from table where menu1 = 'two')) select * from table where id=(select menu2 from table where menu1='two')由menu2来确定id select top 1 * from table awhere exists (select * from table b where b.id < a.id and menul = 'two') select * from t where t.id=(select menu2 from t where menu1='two') select top 1 * from nexted where id>(select id from nexted where menu1='two') declare @id intselect @id = id from table where menu1 = 'two'select top 1 *from table where id > @idorder by id asc 三表关联left join 如何去掉重复值 请教SQL语句 很简单的问题,求时候段的!非常急! 混合验证模式,用户 'sa' 登录失败。原因: 未与信任 SQL Server 连接相关联。 安装完SQL SERVER2000后无法执行添加表命令 (二层c/s)数据库存图片路径,客户端如何读取 求一条简单的sql语句! 很奇怪!SELECT patindex('%,______,%',',cbcyfy,')返回1 请问如何替换字符串中的字符 超级怪问题!100分送上! 一个select语句的结果问题,急 用int做查询条件还是用Varchat做查询条件?哪个效率高?
from table
where id > (select id from table where menu1 = 'two')
order by id asc
select * from 表 where id =(select menu2 from 表 where menu1='two')
from table a
where exists (select 1 from table where id - a.id < 0 and menu1= 'two')
from table a
where exists (select 1 from table where id - a.id < 0 and menu1= 'two')
where exists (select * from table b where b.id < a.id and menul = 'two')
=(select min(id) where id>( select id from table where menu1 = 'two'))
由menu2来确定id
where exists (select * from table b where b.id < a.id and menul = 'two')
select @id = id from table where menu1 = 'two'select top 1 *
from table
where id > @id
order by id asc