I have a MySQL query like this:
SELECT xid, count(yid) AS tot
FROM x_y_map
WHERE z=11
GROUP BY xid
ORDER BY tot
The table is just a simple mapping of X's to Y's. Without the ORDER BY
the query appears to work and displays the number of Y's each X has - one row for each X. However, adding the ordering, all I 开发者_JAVA技巧get is:
xid yid
0 36503
Why is this happening, and how do I get the ordered list?
try direct count in order by like that:
ORDER BY count(yid)
On further research it looks like this is a bug in PHPMyAdmin. Running the same query through PHP gets the correct result. I think PMA is tripping up over so many rows for some reason.
精彩评论