smr/src/sql/select_site_index.sql

25 lines
388 B
MySQL
Raw Normal View History

/*
Select the data we need to display the on the front page
*/
SELECT
posts.id,
posts.post_title,
posts.isanon,
posts.post_time,
authors.name,
posts.views,
COUNT(comments.id)
FROM
posts,
authors
LEFT JOIN comments ON comments.postid = posts.id
WHERE
2021-01-10 22:34:13 +01:00
posts.authorid = authors.id AND
posts.unlisted = 0
GROUP BY
posts.id
ORDER BY
posts.post_time DESC
LIMIT 50
OFFSET :offset;