Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

One to Many Query

Status
Not open for further replies.

kmattera

Technical User
Dec 7, 2004
9
US
I am trying to do a one to many query to display data on a website but can't seem to figure this out.

I have 2 databases -- Teams and Contacts

Teams will have 20 rows with Team Name being one column and description as other. Team Name will come from a Lookup Combo Box.

Contacts will have 100's of rows since each Team will have multiple contacts. I again have used the "Team Name Lookup Combo Box" to tie in the relationship.

I can't figure out how to list the information via my SQL statement on my webpage.

I basically want it to resemble this:

BLUE TYPHOONS
Description - blah blah blah

Team Members
Mickey Mouse
Donald Duck
Goofy

PURPLE CHEETAHS
Description - blah blah blah

Team Members
Snow White
Dopey
Sleepy
Grumpy

But when I try to display the results, I'm getting a row for EACH team member including their Team info repeated each time.

Thanks for your help.

SELECT PU_Teams.ID, PU_Teams.[Team Name], PU_Teams.[Aim Statement], Contacts.ContactName, Contacts.ContactPhone, Contacts.ContactEmail
FROM PU_Teams INNER JOIN Contacts ON PU_Teams.ID = Contacts.Teams
GROUP BY PU_Teams.ID, PU_Teams.[Team Name], PU_Teams.[Aim Statement], Contacts.ContactName, Contacts.ContactPhone, Contacts.ContactEmail
ORDER BY PU_Teams.[Team Name];





 
This is a job for your front end programming language or report writing tool, not SQL. SQL is intended to output your results in rows and columns, and not really for creating a formatted report. Which web technology are you using to do this? Perhaps there is a forum here for that.
 
ASP would be the web technology used for this page. Thanks for your advise!

Kellie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top