I am trying to get information from another SELECT inside of the same query, however I am not too sure how to get the required field I am after.
SELECT t.`id`, t.`title`, t.`author`, t.`content`, ctitle, cid, comments
FROM `tutorials` AS `t`,
(
SELECT tc.`id` as `cid`, tc.`title` as `ctitle`
FROM `tutorial_categories` AS `tc`
WHERE `title` LIKE '%category title'
) AS `c`,
(
SELECT COUNT(com.`id`) as `comments`
FROM `tutorial_comments` AS `com`
WHERE `tutorial_id` = c.cid
) as `comments`
WHERE t.`category` = c.`cid` AND t.`status` = '1'
ORDER BY `id` ASC
I am trying to fetch the id from tutorial_categories and use it in tutorial_comments. All I am trying to do as the final output is get the count of how many comments are listed for each tutorial.
Cheers,
Jacob