避免选择重复的MySQL行

时间:2012-08-01 12:53:14

标签: mysql

我正在选择

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

但在我的表格中我有

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

如何只选择一次?

3 个答案:

答案 0 :(得分:1)

试试这个:

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

这应该是通用的 无论如何,如果你确定你只想要玩家,请使用此

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

答案 1 :(得分:0)

如果您只想playerid,则可以使用DISTINCT

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

答案 2 :(得分:0)

SELECT DISTINCT playerid..

正如@Michael所说