I'm coding a video game and using MySQL to display an icon showing the player where treasure is located. The database stores the locations by their X and Y on a square map. I would like to also count the number of items on each square.
So given a table such as this
Id   x   y
==  ==  ==
1    2   3
2    3   2
3    3   2
4    4   4
5    4   4
6    4   4
I would like to return something to the effect of
x y count
= = =====
4 4 3
3 2 2
2 3 1
                Use GROUP BY clause for results.  
Select x, y, count(*) as 'count' from mytable group by x, y
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With