Mysql查询没有按顺序分组

Not sure if this information is sufficient. I have few tables and i am running this query which is returning me the below results.

SELECT   CONCAT(pm.fname, " " ,pm.lname) AS fullname,cl.id as clubid,pm.id as player_id,

    ( 3959 * acos( cos( radians(50.82) ) * cos( radians( cm.lat ) )
     * cos( radians( -0.373 ) - radians(-0.373) ) + sin( radians(50.82) )
     * sin( radians( cm.lat ) ) ) ) AS distance

FROM clubmapper AS cm

LEFT OUTER JOIN clubs AS cl ON cl.id = cm.club_id

INNER JOIN playermaster AS pm ON pm.id = cm.usertype_id

LEFT JOIN countries AS co ON co.country_code = pm.nationality

WHERE (pm.fname LIKE 'josephthirtye%' OR pm.lname LIKE 'josephthirtye%')   

#group by cm.usertype_id

ORDER BY distance  ASC,pm.fname ASC, pm.lname ASC
LIMIT 0,12

This query returns me the below table:

enter image description here

But i want only the first result whre distance is min. I tried to use group by (commented in the query) but thats giving me the last row. I want only the first row of that player_id

And advice ?

Below is the same query with pretty print:

enter image description here

Some more data: enter image description here

I want unique player_id's whose distance is least

This is the way i solved it. Thanks everybody for suggestions.

SELECT   CONCAT(pm.fname, " " ,pm.lname) AS fullname,cl.id as clubid,pm.id as player_id    

FROM (SELECT ( 3959 * acos( cos( radians(50.82) ) * cos( radians( lat ) )
     * cos( radians( -0.373 ) - radians(-0.373) ) + sin( radians(50.82) )
     * sin( radians( lat ) ) ) ) AS distance FROM clubmapper) AS cm

LEFT OUTER JOIN clubs AS cl ON cl.id = cm.club_id

INNER JOIN playermaster AS pm ON pm.id = cm.usertype_id

LEFT JOIN countries AS co ON co.country_code = pm.nationality

WHERE (pm.fname LIKE 'josephthirtye%' OR pm.lname LIKE 'josephthirtye%')   

group by pm.id

ORDER BY distance  ASC,pm.fname ASC, pm.lname ASC

LIMIT 0,12

But i want only the first result whre distance is min

This query will give you the result with the least distance

SELECT 
    CONCAT(pm.fname, ' ', pm.lname) AS fullname,
    cl.id as clubid,
    pm.id as player_id,
    MIN(3959 * acos(cos(radians(50.82)) * cos(radians(cm.lat)) * cos(radians(- 0.373) - radians(- 0.373)) + sin(radians(50.82)) * sin(radians(cm.lat)))) AS Distance
FROM
    clubmapper AS cm
        LEFT OUTER JOIN
    clubs AS cl ON cl.id = cm.club_id
        INNER JOIN
    playermaster AS pm ON pm.id = cm.usertype_id
        LEFT JOIN
    countries AS co ON co.country_code = pm.nationality
WHERE
    (pm.fname LIKE 'josephthirtye%'
        OR pm.lname LIKE 'josephthirtye%');

I don't know if this is what you wanted but part of your problem seemed getting just one result.