CREATE TABLE `student` (
  `name` varchar(10) DEFAULT NULL,
  `subject` varchar(10) DEFAULT NULL,
  `score` int(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8

INSERT INTO student VALUES('liming','eng',90);
INSERT INTO student VALUES('liming','math',90);
INSERT INTO student VALUES('tom','math',93);
INSERT INTO student VALUES('tom','eng',91);

select * 
from student
where 
CASE
    when score = 90 then name in ('liming', 'tom')
    when score = 91 then name in ('liming', 'tom')
END

 

 

 posted on 2023-01-03 09:51  boye169  阅读(2023)  评论(0编辑  收藏  举报