mysql大于等于号

真是坑:

CREATE TABLE `test01` (
    `interval` INT(5),
    `source` VARCHAR(20)
)  ENGINE=INNODB AUTO_INCREMENT=32 DEFAULT CHARSET=UTF8;
insert into `test01` values(1,"红色");
insert into `test01` values(1,"红色");
insert into `test01` values(1,"红色");
insert into `test01` values(4,"红色");
insert into `test01` values(8,"红色");
insert into `test01` values(12,"红色");
insert into `test01` values(17,"红色");
insert into `test01` values(26,"红色");
insert into `test01` values(90,"红色");
insert into `test01` values(101,"红色");
insert into `test01` values(165,"红色");
insert into `test01` values(182,"红色");
insert into `test01` values(10000,"红色");
insert into `test01` values(1278,"红色");

SELECT 
    `source`,
    CASE
        WHEN 0 < `interval` <= 10 THEN 100
        WHEN 10 < `interval` <= 20 THEN 200
        WHEN 20 < `interval` <= 30 THEN 300
        ELSE 400
    END AS `interval88`
FROM
    `test01`;
    
   

结果全部是100.。。。。


修正后

SELECT 
    `source`,
   `interval`,
    CASE
         WHEN 0<`interval` and `interval`<= 10 THEN 100
        WHEN 10 < `interval`and `interval` <= 20 THEN 200
        WHEN 20 < `interval` and `interval` <= 30 THEN 300
        ELSE 400
    END AS `interval1111`
FROM
    `test01`;

结果满足要求:



结论大约等于号,实际上是个或关系............



你可能感兴趣的:(mysql大于等于号)