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!

Merge two records into one

Status
Not open for further replies.

CSMwebmaster

Programmer
Aug 20, 2007
1
US
I have a query:
SELECT Name, Game FROM Sports

This gives me the following results.

Name | Game
Jane Volleyball
Jane Basketball
Sandy track
Sandy Golf

I would like the result to be using SQL:

Name | Game
Jane Volleyball,Basketball
Sandy Track,Golf

Any Ideas?
 
i'm afraid there is no good ANSI SQL solution

please ask this question in the appropriate forum for your particular database system

the solutions vary wildly depending on which system it is

in MySQL, for example, you can say
Code:
select name
     , group_concat(game) as games
  from daTable
group
    by name
:)

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top