如下表:
id      menu1     menu1    
1       one       2
2       two       3
3       three     2
4       four      1
查询条件是menu1=two要得到的结果是   id=3   menu1=three    menu2=2请问谁知道这个怎么查询?谢谢。

解决方案 »

  1.   

    select top 1 *
    from table
    where id > (select id from table where menu1 = 'two') 
    order by id asc
      

  2.   


    select * from 表 where id =(select menu2 from 表 where menu1='two')
      

  3.   

    Id 连续只要ID + 1 ,不连续就得>
      

  4.   

    select * 
    from table a
    where exists (select 1 from table where id - a.id < 0 and menu1= 'two')
      

  5.   

    select top 1 * 
    from table a
    where exists (select 1 from table where id - a.id < 0 and menu1= 'two')
      

  6.   

    select top 1 * from table a
    where exists (select * from table b where b.id < a.id and menul = 'two')
      

  7.   

    不好意思,后面列名应该是menu2
      

  8.   

    select * from id
    =(select min(id) where id>( select id from table where menu1 = 'two'))
      

  9.   

    select * from table where id=(select menu2 from table where menu1='two')
    由menu2来确定id
      

  10.   

    select top 1 * from table a
    where exists (select * from table b where b.id < a.id and menul = 'two')
      

  11.   

    select * from t where t.id=(select menu2 from t where menu1='two')
      

  12.   

    select top 1 * from nexted where id>(select id from nexted where menu1='two')
      

  13.   

    declare @id int
    select @id = id from table where menu1 = 'two'select top 1 *
    from table 
    where id > @id
    order by id asc