cartch2008
asked on
T-SQL Select Query Question
I have 2 tables. tblContacts and tblAddresses. There is a 1 to many relationship between tblContacts and tblAddresses = a contact can have more than 1 address, and an address can only belong to 1 contact.
Here is what I want to do in pseudo code.
select tblcontacts.lastname,all cities found in tbladdresses for the contact seperated by commas
from tblcontacts, tbladdresses
where tblcontacts.contactid = tbladdresses.addressid
ie:
Jackson New York,Chicago,LA
Smith Boston,London,Toronto,LA
I dont' want:
Jackson New York
Jackson Chicago
Jackson LA
Smith Boston
Smith London
Smith Toronto
Smith LA
Is it possible to do this in 1 query somehow? If so, how?
Here is what I want to do in pseudo code.
select tblcontacts.lastname,all cities found in tbladdresses for the contact seperated by commas
from tblcontacts, tbladdresses
where tblcontacts.contactid = tbladdresses.addressid
ie:
Jackson New York,Chicago,LA
Smith Boston,London,Toronto,LA
I dont' want:
Jackson New York
Jackson Chicago
Jackson LA
Smith Boston
Smith London
Smith Toronto
Smith LA
Is it possible to do this in 1 query somehow? If so, how?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER