how to write the code in php that get the articles’ title with the most replies in latest one week in mysql? eg: the table name is “threads”. the time field is “dateline” whose style is like this (1300774889), the article title is “subject”. the reply field " replies" thank you.i want to get 10 records.
What SQL do you have now?
i guessed the articleid column
SELECT threads.subject
, COUNT(replies.replies) AS replies
FROM threads
LEFT OUTER
JOIN threads AS replies
ON replies.replies = threads.articleid
AND replies.dateline >= UNIX_TIMESTAMP(CURRENT_DATE - INTERVAL 7 DAY)
GROUP
BY threads.subject
ORDER
BY replies DESC LIMIT 10
could i use this (time()-3600247) to represent the latest one week
you command is complicated
yes
yes