Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
bugbite
Starting Member
5 Posts |
Posted - 2004-11-19 : 12:12:17
|
| I have a SQL query that returns several fields from several tables, eg. Title, Subtitle, Author, Binding and Imprint. When these are returned everything seems rosy until there are two authors linked to one title. When this happens Title, Subtitle, Binding and Imprint are repeated which is not required. Is there a way to concatenate the authors from multple records to return a single title with the concatenated authors, instead of repeating titles due to multiple authors?.Example:A query may currently return:Title1 - Subtitle1 - Author 1a - etcTitle1 - Subtitle1 - Author 1b - etcTitle1 - Subtitle1 - Author 1c - etcTitle2 - Subtitle2 - Author 2a - etcTitle3 - Subtitle3 - Author 3a - etcWhen I would likeTitle1 - Subtitle1 - Author 1a, Author 1b, Author 1c - etcTitle2 - Subtitle2 - Author 2a - etcTitle3 - Subtitle3 - Author 3a - etcApologies if this is simple but I have only started learning SQL.My actual SQL code, if you are interested, is:SELECT dbo.edition.ISBN, dbo.edition.title, dbo.party.first_name+' '+dbo.party.surname as name, dbo.edition.reviews, dbo.edition.long_blurb, dbo.series.series_id, dbo.series.series_number,dbo.series.series_title, dbo.edition.sub_title, dbo.edition.about_author, dbo.edition.short_blurb,dbo.series.editors_affiliations, dbo.title.contents, dbo.title.affiliations, dbo.series.series_editorsFROM dbo.edition INNER JOINdbo.series ON dbo.edition.series_id = dbo.series.series_id INNER JOINdbo.title ON dbo.edition.title_id = dbo.title.title_id INNER JOINdbo.agreement ON dbo.edition.edition_id = dbo.agreement.edition_id INNER JOINdbo.role ON dbo.agreement.role_id = dbo.role.role_id INNER JOINdbo.party ON dbo.role.party_id = dbo.party.party_id |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-11-19 : 19:56:14
|
for displaying child data with CSV string use the "The New and Improved Approach" - bottom of the pagefrom http://www.sqlteam.com/item.asp?ItemID=2368put it in a function which returns a varchar and pass a parent id as an argument.Go with the flow & have fun! Else fight the flow |
 |
|
|
|
|
|
|
|