如果它们在 sql 中共享相同的 id 值,如何将它们分组在一起 [英] How to group values together if they share the same id value in sql

查看:38
本文介绍了如果它们在 sql 中共享相同的 id 值,如何将它们分组在一起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将从事相同标题的作者归为一组.目前我有以下查询

I'm trying to group together authors who have worked on the same title. Currently i have the following query

SELECT o.Output_Author_Name, a.Output_Title_Name 
FROM output_author_country o INNER JOIN
     outputlist a
     ON o.Output_ID_fk = a.Output_ID
LIMIT 10

返回

是否有一种简单的方法可以将作者分组?所以它返回

Is there an easy way to group the authors together? So it returns

Floarian Mai, Iacopo Vaglina, Lukas Galke, Using Adversarial...

行包数据返回

  RowDataPacket {
    Organisation_Name: 'APHA, PH1 1RX',
    Output_Title_Name:
     'Comparison of Alternative Meat Inspection Regimes for Pigs From Non-Controlled Housing – Considering the Cost of Error',
    'GROUP_CONCAT(o.Output_Author_Name)':

推荐答案

你可以使用 GROUP_CONCAT:

SELECT Output_Title_Name,GROUP_CONCAT(Output_Author_Name)
FROM output_author_country
GROUP BY Output_Title_Name

这篇关于如果它们在 sql 中共享相同的 id 值,如何将它们分组在一起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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