select a.*,group_concat(f.name separator ',') as asd from dx2.admin_info as a left join dx2.admin_role as af on af.admin_id = a.admin_id left join dx2.role_info as f on af.role_id = f.role_id group by f.name

时间: 2024-04-07 13:33:00 浏览: 16
根据你的查询需求,你想要从表 "dx2.admin_info" 中选择所有列,并将 "dx2.role_info" 表中对应角色的名称使用逗号分隔起来作为一个名为 "asd" 的新列。 然而,根据你提供的查询语句,可能会导致错误,因为你在 GROUP BY 子句中只列出了 "f.name" 列,而没有包含其他非聚合列。这可能会触发之前提到的 "only_full_group_by" 错误。 为了解决这个问题,你可以修改查询,将需要的非聚合列都包含在 GROUP BY 子句中。以下是修改后的查询语句: ```sql SELECT a.*, GROUP_CONCAT(f.name SEPARATOR ',') AS asd FROM dx2.admin_info AS a LEFT JOIN dx2.admin_role AS af ON af.admin_id = a.admin_id LEFT JOIN dx2.role_info AS f ON af.role_id = f.role_id GROUP BY a.admin_id, a.column1, a.column2, ... -- 列出除了聚合函数外的其他列 ``` 请注意,在 GROUP BY 子句中,除了 "f.name" 列外,还需要将 "dx2.admin_info" 表中的其他非聚合列(例如 "a.admin_id"、"a.column1"、"a.column2")都列出来。 这样修改后的查询应该可以成功执行,并返回你想要的结果。记得替换查询中的 "column1"、"column2" 等为实际的列名。

相关推荐

select a.*, b.name activityName, c.name productName, c.member_max memberMax, d.status as complete, group_concat(if(e.face_value is null, "", e.face_value) separator "\n") as rewardAmount, group_concat(if(e.coupon_code is null, "", e.coupon_code ) separator "\n") as couponCode , group_concat(if(e.coupon_id is null, "", e.coupon_id) separator "\n") as caId from marketing_group_tool_group_member a left join marketing_group_tool_group_info d on a.group_id = d.id left join marketing_group_tool_activity b on a.activity_id = b.activity_id left join marketing_group_tool_product_base c on a.product_id = c.product_id left join marketing_group_tool_send_coupon_record e on (a.group_id = e.group_id and a.card_no = e.card_no) left join wx_recommend_organization organization on b.organization_id = organization.id where ((organization.tree_id between 2002000000000000 and 2002999999999999) or (organization.tree_id between 1000000000000000 and 1999999999999999) or (organization.tree_id between 2000000000000000 and 2999999999999999) or (organization.tree_id between 3000000000000000 and 3999999999999999) or (organization.tree_id between 4000000000000000 and 4999999999999999) or (organization.tree_id between 6000000000000000 and 6999999999999999) or (organization.tree_id between 5000000000000000 and 5999999999999999) or (organization.tree_id between 10000000000000000 and 10999999999999999) or (organization.tree_id between 8000000000000000 and 8999999999999999) or (organization.tree_id between 9000000000000000 and 9999999999999999) or (organization.tree_id between 11000000000000000 and 11999999999999999) or (organization.tree_id between 12000000000000000 and 12999999999999999) or (organization.tree_id between 13000000000000000 and 13999999999999999) or (organization.tree_id between 14000000000000000 and 14999999999999999) or (organization.tree_id between 15000000000000000 and 15999999999999999) or (organization.tree_id between 16000000000000000 and 16999999999999999) or (organization.tree_id between 17000000000000000 and 17999999999999999) ) and 1 = 1 group by a.id, a.activity_id , a.group_id , a.product_id , a.activity_referral_code, a.product_referral_code , a.openid , a.unionid , a.nickname , a.head_img , a.mobile , a.is_sub_buy , a.is_sub_progress , a.is_sub_success , a.sort , a.card_no , a.create_time , a.is_received_notice , a.is_received_progress , a.is_received_success , b.name, c.name, c.member_max , d.status order by a.id desc limit 0,20;

最新推荐

recommend-type

如何修改Mysql中group_concat的长度限制

在mysql中,有个函数叫“group_concat”,平常使用可能发现不了问题,在处理大数据的时候,会发现内容被截取了。怎么解决这一问题呢,下面脚本之家小编给大家带来了Mysql中group_concat的长度限制问题,感兴趣的朋友...
recommend-type

MySQL中group_concat函数深入理解

本文通过实例介绍了MySQL中的group_concat函数的使用方法,需要的朋友可以适当参考下
recommend-type

谈一谈数组拼接tf.concat()和np.concatenate()的区别

今天小编就为大家分享一篇谈谈数组拼接tf.concat()和np.concatenate()的区别,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
recommend-type

基于AT89C51单片机的三电梯联动控制系统+全部资料+详细文档(高分项目).zip

【资源说明】 基于AT89C51单片机的三电梯联动控制系统+全部资料+详细文档(高分项目).zip基于AT89C51单片机的三电梯联动控制系统+全部资料+详细文档(高分项目).zip基于AT89C51单片机的三电梯联动控制系统+全部资料+详细文档(高分项目).zip 【备注】 1、该项目是个人高分项目源码,已获导师指导认可通过,答辩评审分达到95分 2、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 3、本项目适合计算机相关专业(人工智能、通信工程、自动化、电子信息、物联网等)的在校学生、老师或者企业员工下载使用,也可作为毕业设计、课程设计、作业、项目初期立项演示等,当然也适合小白学习进阶。 4、如果基础还行,可以在此代码基础上进行修改,以实现其他功能,也可直接用于毕设、课设、作业等。 欢迎下载,沟通交流,互相学习,共同进步!
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

实现实时数据湖架构:Kafka与Hive集成

![实现实时数据湖架构:Kafka与Hive集成](https://img-blog.csdnimg.cn/img_convert/10eb2e6972b3b6086286fc64c0b3ee41.jpeg) # 1. 实时数据湖架构概述** 实时数据湖是一种现代数据管理架构,它允许企业以低延迟的方式收集、存储和处理大量数据。与传统数据仓库不同,实时数据湖不依赖于预先定义的模式,而是采用灵活的架构,可以处理各种数据类型和格式。这种架构为企业提供了以下优势: - **实时洞察:**实时数据湖允许企业访问最新的数据,从而做出更明智的决策。 - **数据民主化:**实时数据湖使各种利益相关者都可
recommend-type

list根据id查询pid 然后依次获取到所有的子节点数据

可以使用递归的方式来实现根据id查询pid并获取所有子节点数据。具体实现可以参考以下代码: ``` def get_children_nodes(nodes, parent_id): children = [] for node in nodes: if node['pid'] == parent_id: node['children'] = get_children_nodes(nodes, node['id']) children.append(node) return children # 测试数
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。
recommend-type

"互动学习:行动中的多样性与论文攻读经历"

多样性她- 事实上SCI NCES你的时间表ECOLEDO C Tora SC和NCESPOUR l’Ingén学习互动,互动学习以行动为中心的强化学习学会互动,互动学习,以行动为中心的强化学习计算机科学博士论文于2021年9月28日在Villeneuve d'Asq公开支持马修·瑟林评审团主席法布里斯·勒菲弗尔阿维尼翁大学教授论文指导奥利维尔·皮耶昆谷歌研究教授:智囊团论文联合主任菲利普·普雷教授,大学。里尔/CRISTAL/因里亚报告员奥利维耶·西格德索邦大学报告员卢多维奇·德诺耶教授,Facebook /索邦大学审查员越南圣迈IMT Atlantic高级讲师邀请弗洛里安·斯特鲁布博士,Deepmind对于那些及时看到自己错误的人...3谢谢你首先,我要感谢我的两位博士生导师Olivier和Philippe。奥利维尔,"站在巨人的肩膀上"这句话对你来说完全有意义了。从科学上讲,你知道在这篇论文的(许多)错误中,你是我可以依