Can't use where clause on correlated columns.
- by Keyo
I want to add a where clause to make sure video_count is greater than zero. Only categories which are referenced once or more in video_category.video_id should be returned.
Because video_count is not a field in any table I cannot do this.
Here is the query.
SELECT category . * , (
SELECT COUNT( * )
FROM video_category
WHERE video_category.category_id = category.category_id
) AS 'video_count'
FROM category
WHERE category.status = 1
AND video_count > '0'
AND publish_date < NOW()
ORDER BY updated DESC;
Thanks for the help.