这个似乎ANSI SQL无法实现吧?TSQL可以实现,另外PL SQL块和存储过程好像也可以实现。

解决方案 »

  1.   

    mysql的select if(b>0,b,a) as c from table
      

  2.   

    根據Gdj(陈水.智商只有129.非卖品) 提供思路寫的if(b>0,b,a)>=$price and if(b>0,b,a)<=$price_a下面是我那天晚上寫的.死了我好多腦細胞.呵呵
    ((($price<=b) and (b<=$price_a)) OR ((($price<=a) and (a<=$price_a)) and (b=0)))那個效率高些?
      

  3.   

    select b as res from tbl where b>0 and a=0 union select a as res from tbl where a>0  and b=0
      

  4.   


    有那么复杂么????michelle0618(小蝶) 就能满足lz需要阿!~
      

  5.   

    if(b=0){
    select a from table
    }else{
    select b from table
    }
      

  6.   

    michelle0618(小蝶) 的好像沒有上面的效率高,最起碼上面只讀一次數據庫,而michelle0618(小蝶)的讀了2次
      

  7.   

    错!union 和or 地执行效率是差不多的
    不过一般来说,很多人都喜欢用
    union 
    这样 效率或许会稍为高点!