表A:
属性 b,c,d
     j,2,3
     k,3,4
现想实现: select b from A where c in {**} or d in{**} 是没问题的,我想请教一下,有没有可以实现类似下面方法的语句
select b from A where (c or d) in {**},当然这样写是不对的,想问一下与这样实现类似但正确的写法  

解决方案 »

  1.   

    就用select b from A where c in {**} or d in{**}吧
      

  2.   

    就用select b from A where c in {**} or d in{**}吧
    ---------------------------
    主要是在{**}里用到变量,写成两个降低了效率,所以想有没有写成一个的,呵呵
      

  3.   

    bonever(云速)你想用变量还是不想用索引~~~~瞎来
      

  4.   

    给你个参考方法 charindex(',**,',','c+','+'d'+',')>0
      

  5.   

    bonever(云速)你想用变量还是不想用索引~~~~瞎来
    -------
    兄弟,说话能不能客气点
      

  6.   

    or有时也可以应用索引,但是用in就比较糟糕,你这个本身就不会快
    charindex同样也不成
      

  7.   

    如果比较是变量串,那怎么也不会快,那么charindex倒是个最简单的写法