kdiggy
07-20-2006, 05:38 AM
I need a little help setting up the logic behind a query. Here is the situation:
I have 2 tables. Product table. Flag table (flagID, productID, date_flagged). Users can flag products. *date_flagged is a INTEGER unix timestamp.
I would like to be able to setup a query where I can pull up products that have been flagged the most in the past 24 hours.
At first I figured I would COUNT() the flags and GROUP BY productID, but this of course will only give me the most flagged all time, and because of the grouping by productID will not allow me to filter it by date.
I really don't see what sort of query can do this for me. Any ideas?
I have 2 tables. Product table. Flag table (flagID, productID, date_flagged). Users can flag products. *date_flagged is a INTEGER unix timestamp.
I would like to be able to setup a query where I can pull up products that have been flagged the most in the past 24 hours.
At first I figured I would COUNT() the flags and GROUP BY productID, but this of course will only give me the most flagged all time, and because of the grouping by productID will not allow me to filter it by date.
I really don't see what sort of query can do this for me. Any ideas?