I'm not that great with mysql commands, so was wondering if there's an easy way to do what I'm attempting:
I have a table like the following:
And am wanting to perform a command where I exact all the data for a certain id, group it together by the item_no, count the number of items in this group, and have it group sorted so that the latest timetamp is fed back at the end of it, sorted by newest timestamp first. Like so:
(for all those IDs matching 10001):
Any ideas?
edit: or would it be better/faster/less resource intensive to see if this can be done in php after just extracting the data in a normal way first?
I have a table like the following:
Code:
id item_no user_id timestamp
1 10001 5057 1263915032
2 10001 3 1263915088
3 10001 5057 1263917853
4 10001 5057 1263917863
5 10001 32 1263921113
6 10002 32 1263921555
And am wanting to perform a command where I exact all the data for a certain id, group it together by the item_no, count the number of items in this group, and have it group sorted so that the latest timetamp is fed back at the end of it, sorted by newest timestamp first. Like so:
(for all those IDs matching 10001):
Code:
totals item_no user_id timestamp
1 10001 32 1263921113
3 10001 5057 1263917863
1 10001 3 1263915088
Any ideas?
edit: or would it be better/faster/less resource intensive to see if this can be done in php after just extracting the data in a normal way first?
Last edited: