sql分组和连接

SELECT
	mr.member_id,
	mr.username,
GROUP_CONCAT(DISTINCT jb.company,jb.start_time,jb.end_time)companys,	
GROUP_CONCAT(DISTINCT en.school)school,
CONCAT(jb.company,'-',en.school) wawwa,
GROUP_CONCAT(DISTINCT CONCAT(jb.company,' ',jb.start_time,':',jb.end_time)) job -- 重点
GROUP_CONCAT(DISTINCT CONCAT(en.school,' ',en.position,' ',en.start_time,':',en.end_time)) education  -- 重点
FROM
	member mr -- 主表
	RIGHT  JOIN job jb ON mr.member_id = jb.member_id -- 明细
	LEFT JOIN education en ON mr.education_id = en.education_id -- 明细
	GROUP BY member_id

 

posted @ 2018-12-14 19:40  adstat  阅读(502)  评论(0编辑  收藏  举报