需要帮助在Mysql中编写查询 [英] Need an help to write query in Mysql

查看:67
本文介绍了需要帮助在Mysql中编写查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述







我有桌子好像



 Id GroupName 
--- --------
1 science
2 science
3 science
4 arts
5 arts
6 commerce





我需要写一个查询来获得这样的输出



 Id GroupName 
--- --------
1,2,3 science
4,5 arts
6商业





请帮我解决这个问题

解决方案

看起来像一个家庭作业。你可以从这里开始 MySQL:多行作为逗号分隔的单行 [ ^

Hi,


I have table like

Id     GroupName
---    --------
1      science
2      science
3      science
4      arts
5      arts
6      commerce



I need to write a query to get an output like this

Id     GroupName
---    --------
1,2,3      science
4,5        arts
6          commerce



Please help me resolve this

解决方案

Seems like a homework. You can start from here MySQL : Multiple row as comma separated single row[^]


这篇关于需要帮助在Mysql中编写查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆