okey, i try the other way now:
how get top 3 time each map, like this:
Load the data into an associative array where the keys are the 'map' fields and their value is an array of the times. Then sort the array(s) and output only the first (or last) 3 elements of each array.
Like that i get only first times:
SELECT a.* FROM records a INNER JOIN(SELECT map, MIN(time) min_time FROM records GROUP BY map) b ON a.map = b.map AND a.time = b.min_time order by map
This works well, but why it is so slow?:
and one more thing, how i get like:
SELECT * FROM records s WHERE(SELECT COUNT(*) FROM records f WHERE f.map = s.map AND f.time <= s.time) <= 3
Use the EXPLAIN function to see how mysql executes the statement.
Thanks, but how i get this name count? i try something:
but its wrong, it give me only one row and count show rows amount :(
SELECT map, time, count(name) FROM records s WHERE(SELECT COUNT(*) FROM records f WHERE f.map = s.map AND f.time <= s.time) <= 3
maybe i need make two querys?
Well, that's what the count() function does, it returns the number of rows. Did you expect it to do something else?
It's not clear to me what you're trying to do with that sql statement.
If we go back to your prior post where you wanted to get the top 3 times for each map, you could and it would be easier to calculate/extract that via the php code rather than trying to build a single sql statement. I seriously doubt that you'll be able to construct an sql statement that returns the data exactly the way you want.