image.png
    1、IF语句

    1. select x,y,z,IF(x+y>z AND x+z>y AND y+z>x,"Yes","No") triangle from triangle

    2、CASE语句

    1. select
    2. * ,
    3. (
    4. case
    5. when x+y>z and x+z>y and y+z>x then 'Yes'
    6. else 'No'
    7. end
    8. )triangle
    9. from
    10. triangle

    二、

    image.png

    1. update Salary set sex =if(sex="m","f","m")

    三、Case-when-then-else-end
    image.png

    1. select
    2. id
    3. , sum(case `month` when 'Jan' then revenue else null end) as Jan_Revenue
    4. , sum(case `month` when 'Feb' then revenue else null end) as Feb_Revenue
    5. , sum(case `month` when 'Mar' then revenue else null end) as Mar_Revenue
    6. , sum(case `month` when 'Apr' then revenue else null end) as Apr_Revenue
    7. , sum(case `month` when 'May' then revenue else null end) as May_Revenue
    8. , sum(case `month` when 'Jun' then revenue else null end) as Jun_Revenue
    9. , sum(case `month` when 'Jul' then revenue else null end) as Jul_Revenue
    10. , sum(case `month` when 'Aug' then revenue else null end) as Aug_Revenue
    11. , sum(case `month` when 'Sep' then revenue else null end) as Sep_Revenue
    12. , sum(case `month` when 'Oct' then revenue else null end) as Oct_Revenue
    13. , sum(case `month` when 'Nov' then revenue else null end) as Nov_Revenue
    14. , sum(case `month` when 'Dec' then revenue else null end) as Dec_Revenue
    15. from Department group by id