if语句的第一个表达式如果是一个范围,可以拆分为两个表达式并通过and连接,如下所示
select score,if(score>=70 and score<80,1,0) as mendium
from sc;
但是,绝对不能直接如下所示,否则结果全是真,不符合需求
select score,if(70<=score<80,1,0) as mendium
from sc;
if语句的第一个表达式如果是一个范围,可以拆分为两个表达式并通过and连接,如下所示
select score,if(score>=70 and score<80,1,0) as mendium
from sc;
但是,绝对不能直接如下所示,否则结果全是真,不符合需求
select score,if(70<=score<80,1,0) as mendium
from sc;