All pastes #506597 Raw Edit

Stuff

public text v1 · immutable
·published 2007-05-24 02:36 UTC
rendered paste body
SELECT
	id,
	title,
	category_id,
	(SELECT title FROM categories WHERE id = articles.category_id LIMIT 1) AS category_title,
	(SELECT COUNT(0) FROM article_comments WHERE article_id = articles.id) AS num_comments
FROM articles
WHERE UNIX_TIMESTAMP(datetime) < (NOW() - (60 * 60 * 24 * 7))
ORDER BY num_comments DESC, datetime DESC
LIMIT 100