您如何将子表的值连接到搜索结果的单个列中?

时间:2018-07-19 13:24:01

标签: tsql

有两个表:CONTACT和CONTACT_GROUP。我需要检索联系人组的名称以及该组下的所有电子邮件地址(请参见下面的查询结果):

CONTACT_GROUP
ID   NAME
1    Sales Team
2    IT Team


CONTACT
ID    CONTACT_GROUP_ID  Name      Title            Email
1     1                 Sally     Sales Lead       sally@company.com
2     2                 Bob       Programmer       bob@company.com
3     1                 Jim       Sales Manager    jill@company.com

Desired query results:
CONTACT_GROUP_NAME     GROUP_EMAILS
Sales Team             sally@company.com jill@company.com
IT Team                bob@company.com

0 个答案:

没有答案