phantom
Nov 8th 2007, 5:45 pm
I have this table structure:
name | timeUpdate | approved | private | Product
where timeUpdate is a mysql timestamp
and the table can have many names with many different products but some of the names and products are the same too.
like:
joe | timestamp | 1 | 0 | widget respectively.
what I need to do is total up how many different names have chosen the same product and and sort them by the most recent timestamp and have the product that is chosen the most at the top.
So far I have this code:
select *, COUNT(name) from archive
WHERE DATE_SUB(CURDATE(),INTERVAL 1 DAY) <= timeUpdate
and (approved='1' and private='0' ) GROUP by product order by
COUNT(name) DESC, id Limit 20 ;
Which works but does not sort them by the most recent entry. It does sort by the product with most counts though.
Any ideas On how to fix it so that the most recent updated items are listed first but also the ones with the most count are at the top?
Thanks in advance!
name | timeUpdate | approved | private | Product
where timeUpdate is a mysql timestamp
and the table can have many names with many different products but some of the names and products are the same too.
like:
joe | timestamp | 1 | 0 | widget respectively.
what I need to do is total up how many different names have chosen the same product and and sort them by the most recent timestamp and have the product that is chosen the most at the top.
So far I have this code:
select *, COUNT(name) from archive
WHERE DATE_SUB(CURDATE(),INTERVAL 1 DAY) <= timeUpdate
and (approved='1' and private='0' ) GROUP by product order by
COUNT(name) DESC, id Limit 20 ;
Which works but does not sort them by the most recent entry. It does sort by the product with most counts though.
Any ideas On how to fix it so that the most recent updated items are listed first but also the ones with the most count are at the top?
Thanks in advance!