Joe Somebodey
Joe Somebodey

Reputation: 11

mysql combining records from one table

I have a single table that uses test# as the primary key. Here is what that table looks like:

Test# Name VerbalScore readingScore    Notes
  1   Bobby  92                       Good job
  2   Bobby                  40       You Suck Bobby 

The problem is I want to view and be able to see when there are multiple verbal scores for the same Name (so be able to see if the person took the same test more than once).

I want to have some kind of select statement to get this result from the above table:

1   Bobby   92   40   Good job, You Suck Bobby

Is that possible?

Upvotes: 0

Views: 44

Answers (1)

Jerome WAGNER
Jerome WAGNER

Reputation: 22442

I am not totally sure I understand what you mean by "see when there are multiple verbal scores" but with mysql 5+, try

SELECT
   Name,
   GROUP_CONCAT(VerbalScore),
   GROUP_CONCAT(readingScore),
   GROUP_CONCAT(Notes)
FROM
   myTable
GROUP BY
   Name;

GROUP_CONCAT is a mysql specific grouping function.

Upvotes: 1

Related Questions