SQL筛选两个字段同时满足条件的结果

 原始表
现在有一张student表,包含三个字段:s_id,c_id,s_score:


目的1:如果只保留得到s_id为01,s_score为80的结果

输入语句:

select * from score where case when s_id =01 and s_score =80 then 0 else 1 end=
0;


结果:



目的2:筛选除同时满足s_id为01,s_score为80以外的所有数据
输入语句:

select * from score where case when s_id =01 and s_score =80 then 0 else 1 end=
1;


输出结果:


posted @ 2022-09-16 15:15  小牛同学丶  阅读(796)  评论(0编辑  收藏  举报