0

I am selecting rows with

SELECT `playerid` FROM `lb-world` WHERE replaced=50 AND type=0 >= 0.01

But in my table I have

playerid | replaced | type | date
12       | 50       | 0    | 2010
12       | 50       | 0    | 2011
12       | 50       | 0    | 2012

How to select it just once?

1
  • 1
    SELECT DISTINCT playerid.... Commented Aug 1, 2012 at 12:54

3 Answers 3

1

Try this:

SELECT `playerid` FROM `lb-world` 
WHERE replaced=50 AND type=0
GROUP BY playerid, replaced, type

This should be generic.
Anyway, if you're sure you just want playerid, use this

SELECT DISTINCT playerid FROM lb-world
WHERE replaced=50 AND type=0
Sign up to request clarification or add additional context in comments.

3 Comments

Why GROUP BY? There's only playerid in the select list
@Michael: yes, you're right... but if he wants to add some field it's still working... anyway, ok I will change my answer
I think using GROUP BY is perfectly valid as well. As stated in MySQL documentation, in term of optimization, both functions are very close. dev.mysql.com/doc/refman/5.0/en/distinct-optimization.html
0

If you only want playerid, you can use DISTINCT

SELECT DISTINCT `playerid` FROM `lb-world` WHERE replaced=50 AND type=0 >= 0.01

Comments

0
SELECT DISTINCT playerid..

as @Michael said

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.