2

A MySQL query retrieves:

totalpoints --  name 
55 -- John Doe
55 -- John Doe
55 -- John Doe
55 -- John Doe
55 -- John Doe
21 -- Jean London
21 -- Jean London
13 -- Mark Derry
13 -- Mark Derry
13 -- Mark Derry
13 -- Mark Derry
4 -- Lara Croft
1 -- Ryan Mirtle
1 -- Ryan Mirtle
1 -- Ryan Mirtle

I need to show in a php page just:

totalpoints --  name 
55 -- John Doe
21 -- Jean London
13 -- Mark Derry
4 -- Lara Croft
1 -- Ryan Mirtle

How can I get rid off the repeated results? Thanks a lot

5 Answers 5

1

What about using DISTINCT? Seems pretty easy... But you actually tried to google it? ou would have found it in no time.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a ton!! Too new to mysql :)
1
select name,totalpoints
from table
group by name
order by totalpoints desc

Comments

1
select distinct name,totalpoints from table

Comments

1

Very easy. use following query:

SELECT totalpoints, name
FROM table_name
GROUP BY name
ORDER BY totalpoints DESC

Comments

0

Please use DISTINCT keyword in your query to avoid duplicate entries

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.