Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 7th, 2004, 10:15 AM
cncoats cncoats is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 2 cncoats User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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!!

Reply With Quote
  #2  
Old January 7th, 2004, 06:05 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
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

Reply With Quote
  #3  
Old January 30th, 2004, 02:33 PM
Walrod Walrod is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 1 Walrod User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft SQL Server > Combining Data in Records


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT