Database: MS SQL Server 2012
I have an app that I'm building where I'm storing family information in one table, and then the members of a family in another. This just seems to make the most sense. Here's a boiled down version of the table:
What I want/need to do is return data so that I can output something like this (without the header):
I'd like to do something like this:
Is this possible? If so, what's the syntax?
Thanks,
Pete
I have an app that I'm building where I'm storing family information in one table, and then the members of a family in another. This just seems to make the most sense. Here's a boiled down version of the table:
Code:
tblMemberFamilies: (one record per family)
memberFamilyID (ID,PK)
memberFamilyName (varchar)
tblMembers: (multiple records per family)
memberID (ID,PK)
memberFamilyID (int, FK)
memberFirstName (varchar)
Code:
Family Name Family Members
Jones Robert, Rhonda, Ralph, Rachel
Smith Jim, Jane, Joe, Janet
I'd like to do something like this:
Code:
select MF.memberFamilyName, (select [first names as a comma delimeted list] from tblMembers M where m.memberFamilyID = MF.memberFamilyID) AS familyMembers
from tblMemberFamilies MF
Is this possible? If so, what's the syntax?
Thanks,
Pete