ShugNiggurath
Technical User
Hello,
I'm not an expert in mySQL, hence being here!
I've a database 'news' that has several sections 'sec', I store records as 'published' and have a counter 'read_count' which is increased by 1 each time it is viewed.
I want to be able to list the top 6 stories as most read, but want also to limit the time backwards on stories to 5 days - there are a minimum of 6 stories published each day.
SQL:
SELECT * FROM news WHERE sec='$sec' AND unix_timestamp(published) >= (unix_timestamp(NOW()) - 600000) ORDER BY read_count DESC LIMIT 0,30";
As I understand it, the unix_timestamp command is asking the database to look back 600000 seconds from NOW and then order the results by the read_count limited to 30 rows in highest - lowest order.
The results are not reflecting what they should be. Can anyone help show me where I'm going wrong?
Regards,
Hugh
I'm not an expert in mySQL, hence being here!
I've a database 'news' that has several sections 'sec', I store records as 'published' and have a counter 'read_count' which is increased by 1 each time it is viewed.
I want to be able to list the top 6 stories as most read, but want also to limit the time backwards on stories to 5 days - there are a minimum of 6 stories published each day.
SQL:
SELECT * FROM news WHERE sec='$sec' AND unix_timestamp(published) >= (unix_timestamp(NOW()) - 600000) ORDER BY read_count DESC LIMIT 0,30";
As I understand it, the unix_timestamp command is asking the database to look back 600000 seconds from NOW and then order the results by the read_count limited to 30 rows in highest - lowest order.
The results are not reflecting what they should be. Can anyone help show me where I'm going wrong?
Regards,
Hugh