Pull entire row per user based on MAX(Column) MySQL I am trying to pull whole record from database for the highest "Score" column per user.

TestTable structure

------------------
ID | Name | Score|
------------------
1  | john | 10
2  | mark | 20
3  | ted  | 15
4  | john | 5
5  | ted  | 50
6  | ted  | 70


So when I run

SELECT ID, Name, MAX(Score)
FROM TestTable
GROUP BY Name


I want the query to return entire row for highest score per user.

This is what I am expecting:

2  | mark | 20
1  | john | 10
6  | ted  | 70


But it does not necessarily return correct rows. It always return MAX(Score) but other values are not necessarily from the same row.

This is what I am getting:

1  | john | 20
2  | mark | 10
3  | ted  | 70


How can I pull this properly?
I am using MySQL.

I need it to perform good as this will be a big query pulling a lot of data from big tables.

Please help :)
You need to group by both ID and Name:

SELECT ID, Name, MAX(Score)
FROM TestTable
GROUP BY ID, Name