Sql用left join查询结果的重复行数据怎么去掉?如图
语句是:selectsc.Id,s.Sname,c.CnamefromSelectCoursescleftjoinStudentsons.Sno=sc.Snoleftjo...
语句是:
select sc.Id ,s.Sname, c.Cname from SelectCourse sc
left join Student s on s.Sno = sc.Sno
left join Course c on c.Cid = sc.Cid
我想把同一个学生的Sno、Sname不在多行里显示、只在一行里显示怎么弄啊? 展开
select sc.Id ,s.Sname, c.Cname from SelectCourse sc
left join Student s on s.Sno = sc.Sno
left join Course c on c.Cid = sc.Cid
我想把同一个学生的Sno、Sname不在多行里显示、只在一行里显示怎么弄啊? 展开
展开全部
select Sno,Sname,concat(Cname) as Cname from (
select sc.Id ,s.Sname, c.Cname from SelectCourse sc
left join Student s on s.Sno = sc.Sno
left join Course c on c.Cid = sc.Cid
) t group by Sno;
更多追问追答
追答
select Sno,Sname,grouup_concat(Cname) as Cname from (
select sc.Id ,s.Sname, c.Cname from SelectCourse sc
left join Student s on s.Sno = sc.Sno
left join Course c on c.Cid = sc.Cid
) t group by Sno;
不好意思,漏了个字母
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询