-
@MySQL---同一属性的多值过滤
方式一
select a.user_name,b.skill,b.skill_level from user1 a join user1_skills b on a.id =b.user_id where skill in ('变化','念经') and skill_skill>0;
方式二
select a.user_name,b.skill,c.skill from user1 a join user1_skills b on a.id=b.user_id and b.skill='念经' join user1_skills c on c.user_id=b.user_id and c.skill='变化' where b.skill_level>0 and c.skill_level>0;
查看全部 -
上节没实现
查看全部 -
未实现
查看全部 -
使用关联方式实现多属性的查询查看全部
-
如何在子查询中匹配两个值?查看全部
-
子查询:这个查询是另外一个查询的条件,称作子查询。查看全部
-
SQL同属性的多值过滤查看全部
-
同一属性多值过滤查看全部
-
多属性任取其中几个的查询例子查看全部
-
累进税问题,阶梯函数查看全部
-
select a.user_name from user1 a join user1_skills b on b.user_id = a.id where b.skill in ('念经','变化','腾云','浮水',) and b.skill_level>0 group by a.user_name having couint(*)>=2查看全部
-
Select a.user_name,b.skill,c.skill,e.skill From user1 a From user1 a Left join user1_skill b on a.id =b.user_id and b.skill='念经' and b.skill level>0 Left join user1_skill c on a.id = c.user_id and c.skill='变化' and c.skill_level>0 Left join user1_skill d on a.id = d.user_id and d.skill = '腾云' and c.skill_level>0 Left join user1_skill e on a.id = e.user_id and e.skill = '浮水' and e.skill_level>0 Where (case when b.skill is not null then 1 else 0 end) +(case when c.skill is not null then 1 else 0 end) +(case when d.skill is not null then 1 else 0 end) +(case when e.skill is not null then 1 else 0 end)>=2;查看全部
-
多列过滤的使用场景:查看全部
-
select user_name from user1 where id in (select user_id from user_kills); 使用子查询可以避免由于子查询中的数据产生的重复。 select a.user_name from user1 a join user_kills b on a.id =b.user_id; 会产生重复记录 select distinct a.user_name from user1 a join user_kills b on a.id =b.user_id; 使用distinct去除重复记录查看全部
-
内容简介:查看全部
举报
0/150
提交
取消