id   qtag           dataset             qid
39  Q15_M1 是否发生以下症状?          2413
40  Q15_M2 是否发生以下症状?   2413
55  Q22_M1 不继续随访的原因有哪些 2451
56  Q22_M2 不继续随访的原因有哪些 2451
57  Q22_M3 不继续随访的原因有哪些 2451
58  Q22_M4 不继续随访的原因有哪些 2451
59  Q22_M5 不继续随访的原因有哪些 2451
60  Q22_M6 不继续随访的原因有哪些 2451
如何用select语句查询只显示id为39和55的。

解决方案 »

  1.   

    select  * from tb where id in (39,55)
      

  2.   

    select  * from tb where id =39 or id =55
      

  3.   


    SELECT * FROM TableName where id =39 or id=55
      

  4.   

    select 
      *
    from tb t
    where not exists(select * from tb where qid=t.qid and id<t.id)
      

  5.   

    select * from tb where id=39 or id=55
      

  6.   


    --LZ应该是要着个吧
    select * from TableName a where exists(select 1 from TableName where a.qtag= qtag)
      

  7.   

    select  * from tb where id in (39,55)
      

  8.   

    select *
    from    tb
    where ID  in (39,55);
      

  9.   

    declare @t table (id int ,qtid varchar(6),dataset varchar(40),qit int )
    insert into @t 
    select 39,'Q15_M1','是否发生以下症状?',2413 union all
    select 40,'Q15_M2','是否发生以下症状?',2413 union all
    select 41,'Q22_M1','不继续随访的原因有哪些',2451 union all
    select 42,'Q22_M2','不继续随访的原因有哪些',2451 union all
    select 43,'Q22_M3','不继续随访的原因有哪些',2451 union all
    select 44,'Q22_M4','不继续随访的原因有哪些',2451 select * from @t where ID IN (select min(id) from @T GROUP BY QIT )
      

  10.   

    --39 Q15_M1 是否发生以下症状? 2413
    --41 Q22_M1 不继续随访的原因有哪些 2451