数据库SQL Case...when...then...end的用法!

每次前端绑定数据的时候!如1:已支付 0:未支付 我们要把数字转换为对应的字符!   就可以用到  Case...when...then...end

    select   (case
           when o.PAYMENTMETHODID = 0 then  '货到付款'
           when o.PAYMENTMETHODID < 0 then  '在线支付'
           else
            ' '
          end)  paymentName  from  st_order  o

原文地址:https://www.cnblogs.com/TanYong/p/5101460.html