MySQL判断语句case when then用法(等同于if...else...)

一、语法1: case when ... then ... end ...

select

name,

age,

case type

        when 0 then 'a类型'

        when 1 then 'b类型'

        end as 别名

from user

二、语法2: case when ... then ..esle... end ...

select

name,

age,

case type

        when 0 then 'a类型'

        when 1 then 'b类型'

        esle '其它类型'

        end as 别名

from user

你可能感兴趣的:(mysql,mysql)