I'm still getting the hang of more advanced MySQL queries, so bear with me here...
I have a table (1 table) with the following columns: name
, source
, destination
, count
I want to group my results by name
, then subgroup them by the pairing between destination
and source
.
So far all I have is this query:
SELECT name, destination, source, COUNT(*) FROM clicks_today GROUP BY name, destination, source
Which gives me groups like this:
group 1
- name 1
- destination 1
- source 1
group 2
- name 1
- destination 2
- source 2
(etc)
What I'd really like is something like this:
group 1
- name 1
- destination 1
- source 1
- destination 2
- source 2
group 2
- name 2
- destination 1
- source 1
- destination 2
- source 2
I'm using PHP to query and display my results, pulling my results with mysql_fetch_assoc
. I want an array inside an array, basically.
Does that make sense? How can I do this?