I have table like this:
+------+-------+
| user | data |
+------+-------+
| 1 | a |
+------+-------+
| 1 | b |
+------+-------+
| 2 | c |
+------+-------+
I need to get something like:
Array
(
[1] => 2
[2] => 1
)
Get unique user and count the instances in data row, any ideas?
I’ve tried with this query:
SELECT DISTINCT user from table ORDER BY ID DESC
You should use
GROUP BYfor this.