select a.user_name,b.timestr,max(b.kills) kills from user1 a join user_kills b on a.id=b.user_id group by a.
id; 不知道这样行不行
id; 不知道这样行不行
2016-12-22
join on 只保留两个表都存在的数据。
left join on : 会保留左表的全部数据,不存在的字段用NULL表示。
left join on : 会保留左表的全部数据,不存在的字段用NULL表示。
2016-10-29
通过join进行过滤的思路很赞。怕有的同学看不清楚sql,我这里根据记忆重写一遍:
select a.user_name, b.skill, c.skill
from user1 as a inner join user_skills as b on a.id = b.user_id and b.skill = '念经'
inner join user_skills as c on b.user_id = c.user_id and c.skill = '变化'
where b.skill_level > 0 and c.skill_level > 0;
select a.user_name, b.skill, c.skill
from user1 as a inner join user_skills as b on a.id = b.user_id and b.skill = '念经'
inner join user_skills as c on b.user_id = c.user_id and c.skill = '变化'
where b.skill_level > 0 and c.skill_level > 0;
2016-10-29