|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Combining Data in Records
Hi,
I have two tables as follows: Table 1 (Issue): IssueID, Title, History Table 2 (Comments): IssueID, CommentID, Comment There is a one to many relationship from Table1 to Table 2 (that is, one issue can have many comments. I am printing an Issue Report but cannot find a way to combine all of the comments for a given report into one record. Since they are not being combined, the dataset contains multiple records with identicle IssueIDs. So, I need to figure out a way to return a dataset: IssueID, Title, History, Comment1 + Comment2 + ... + CommentN (where Comment1, etc. have the same IssueID). Also, this dataset is bound to a .NET datagrid. Anyone have any ideas? Any help would be much appreciated!! |
|
#2
|
||||
|
||||
|
The following SQL will return the all the issues, along with their comments
Code:
SELECT issue.issueid, issue.table, comment FROM issue INNER JOIN comments ON issue.issueid = comments.issueid |
|
#3
|
|||
|
|||
|
I have the same problem as the original poster, but the suggested response does not solve the problem.
The result I am looking for (using the original schema names) is a single row for each Issue ID, with each row containing all of the comments for that particular issue. That is, each row could have a different number of comments than the other rows. Essentially, I would like to join multiple rows in the same table together, based on one (or more) keys. Is this possible with just SQL, or do you need a custom reporting package (or Excel, which I think can do this with pivot tables)? Thanks. |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft SQL Server > Combining Data in Records |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|