将mysql中一行中的几个字段 转换成一列并从其他数据库中查对应的邮件信息

--将项目中的总监,经理,等的邮箱合并为一行
SELECT GROUP_CONCAT(t.USER_EMAIL SEPARATOR ' ') mail_address   FROM portal.t_acl_userinfo AS t  WHERE t.username IN
(SELECT DISTINCT a FROM (
SELECT * FROM (
SELECT XM_MANAGER a FROM xm_main WHERE xm_code='p20190132') A
UNION ALL
SELECT * FROM (
SELECT XM_CONTACT a FROM xm_main WHERE xm_code='p20190132') B
UNION ALL
SELECT * FROM (
SELECT XM_GENERAL a FROM xm_main WHERE xm_code='p20190132') C
) s)AND t.user_email IS NOT NULL

mysql

posted @ 2019-11-06 15:38  Smilevv-45  阅读(427)  评论(0编辑  收藏  举报