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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to combine multiple records for the same item into one line

Status
Not open for further replies.

graziaR

Programmer
Jul 28, 2006
14
US
Hi,
I have a table, call it TEST, in which a records of a person's test dates and scores are kept.
For instance, a person might have taken twice a toefl test and one a math test. The table would look like this:
personId test score date
1111 toefl 234 02/04/2005
1111 toefl 444 03/07/2006
1111 math 333 05/06/2006

I woudl like to loop through the records of that person and to put them all on one line. That is, I woudl like the result to show something like this:
personId test_1 score_1 date_1 test_2 score_2 date_2 test_3 score_3 date_3 ....

Is this at all possible with MySQL ? I am using Oracle 9i.

Many thanks for any suggestion !
 
You could use:
[tt]
SELECT
personid,
GROUP_CONCAT(CONCAT(test,' ',score,' ',testdate))
results
FROM tblname
GROUP BY personid
[/tt]
 
what does "Is this at all possible with MySQL ? I am using Oracle 9i" mean?

there is no GROUP_CONCAT function in oracle

which database are you using, mysql or oracle?

r937.com | rudy.ca
 
Thank you, I posted my question on the forum you suggest.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top