我有以下查询可以正常获取正确的电子邮件,并给出以下结果: - user1@company.com - user2@company.com - 等
问题:如何添加 MySQL GROUP_CONCAT函数,以便结果用逗号分隔:- user1@company.com、user2@company.com 等
这只是我的联合查询的一部分:
- 当我向它提供票号时,它会检查票上的票证类型值并仅返回那些在后端表中检查了该类型的用户。
SELECT CONCAT(tblemailaction.uea_User, "@company.com") AS User_email, tblemailaction.uea_ADSL
FROM tblemailaction, tbltickets, tbltickettype
WHERE tbltickets.ttType = tbltickettype.ttDesc
AND tbltickettype.ttID = tblemailaction.uea_ADSL
AND ttNum = <cfqueryparam cfsqltype="cf_sql_integer" value="#url.id#">
UNION ALL
SELECT CONCAT(tblemailaction.uea_User, "@company.com") AS User_email, tblemailaction.uea_ADSL_INSTALL
FROM tblemailaction, tbltickets, tbltickettype
WHERE tbltickets.ttType = tbltickettype.ttDesc
AND tbltickettype.ttID = tblemailaction.uea_ADSL_INSTALL
AND ttNum = <cfqueryparam cfsqltype="cf_sql_integer" value="#url.id#">
UNION ALL
SELECT CONCAT(tblemailaction.uea_User, "@company.com") AS User_email, tblemailaction.uea_Cabling
FROM tblemailaction, tbltickets, tbltickettype
WHERE tbltickets.ttType = tbltickettype.ttDesc
AND tbltickettype.ttID = tblemailaction.uea_Cabling
AND ttNum = <cfqueryparam cfsqltype="cf_sql_integer" value="#url.id#">
UNION ALL
SELECT CONCAT(tblemailaction.uea_User, "@company.com") AS User_email, tblemailaction.uea_Calix
FROM tblemailaction, tbltickets, tbltickettype
WHERE tbltickets.ttType = tbltickettype.ttDesc
AND tbltickettype.ttID = tblemailaction.uea_Calix
AND ttNum = <cfqueryparam cfsqltype="cf_sql_integer" value="#url.id#">