mysql select if

    xiaoxiao2021-03-25  160

    #比较条件

    SELECT IF(1<2,'trur','false');

    SELECT IF(STRCMP('test','test1'),'no','yes');

    #条件为真 SELECT IF(5,1,0); SELECT IF(0.1,1,0); SELECT IF(1,1,0); #条件为假 SELECT IF(0,1,0); SELECT IF('a',1,0);

    #案例:分数大于60为pass,否则为fail

    SELECT IF(score>=60,’pass’,’fail’) FROM score;

    #分别统计pass、fail的个数

    SELECT count (IF(score>=60,’pass’,’fail’)) FROM score group by score

    SELECT IF(STRCMP('test','test1'),'no','yes');

    转载请注明原文地址: https://ju.6miu.com/read-2150.html

    最新回复(0)