select * from yok_GroupPurchaseItem where ItemID != 43 and ItemID != 44 and ItemID != 45
  and ItemID != 46 and ItemID != 47
能不能把这条SQL语句给压缩一下,太长了,
批量删就能这样写 delete from table  where id in(1,2,3)

解决方案 »

  1.   

    not in
    不过效率貌似不好
      

  2.   

    select * from tablename where id not in(1,2,3,4)
      

  3.   

    select * from yok_GroupPurchaseItem where ItemID not in (43,44,45,46,47)
      

  4.   

    select * from yok_GroupPurchaseItem where ItemID not in(44,45,46,47)select * from yok_GroupPurchaseItem where ItemID not between 44 and 47 
      

  5.   

    select * from yok_GroupPurchaseItem where ItemID<43 and ItemID>47
      

  6.   

     not in  , in   效率都不好   LZ 如果对效率没有要求 就用这吧
      

  7.   

    select * from yok_GroupPurchaseItem where ItemID not in( 43 ,44 ,45,46 ,47)
      

  8.   

    一般 = 的效率最高,然后是EXISTS 最差的是in//我只用过这三种
      

  9.   

    beween 1 and 4   这个行吗?
      

  10.   


    select * from yok_GroupPurchaseItem  where ItemID <43 and ItemID >47