Kód: Vybrať všetko
SELECT a.title AS articles_title,
a.content AS articles_content,
a.excerpt AS articles_excerpt,
a.slug AS articles_slug,
a.views AS articles_views,
a.views AS articles_views,
CONCAT(up.first_name, ' ', up.last_name) AS articles_author,
DATE_FORMAT(a.created, '%T %d.%m.%Y') AS articles_created,
(SELECT IFNULL(ROUND(AVG(av.vote), 1), 0) FROM articles_votes av WHERE a.id = av.article_id) AS articles_votes,
(SELECT COUNT(ac.id) FROM articles_comments ac
WHERE a.id = ac.article_id) AS articles_totalcomments
FROM (`articles` a)
JOIN `user_profiles` up ON `a`.`author_id` = `up`.`user_id`
WHERE `id` = 9
ORDER BY `a`.`created`