1. 程式人生 > >mysql語法_case_when_then

mysql語法_case_when_then

case when 條件1 and 條件2      then 條件成立業務語句      else 條件不成立業務語句end

例子一 select      case when id>5              then '大數'              else '小數'     end as 'aaa' from t_goods;例子二 也可以用於update語句 <update id="updateGroupOrderAfterOrderExpired">     update t_group_order     set state= case when expire_time &lt; now()                      then '${@

[email protected]}'                     else state end     where id = #{groupOrderId} ; </update>