I want to get the number of records that are selected in the main query into a subquery
Query that i am currently trying to execute is:
SELECT cat_id,category_name,seo_name,(SELECT count(category_name) FROM ccs_coupons WHERE (category_name LIKE category_name OR website_name LIKE category_name OR description LIKE LIKE category_name OR url_desc LIKE category_name )) FROM `ccs_coupons` WHERE category_name like 'a%' GROUP BY category_name ORDER BY category_name ASC LIMIT $page,$config
You cannot put the
HAVING
clause on the outer query because it is not an aggregate query. Try this instead:You can just use a join between the two tables instead of the correlated subquery:
Edit, based on your update, you should still be able to use something like this:
Or even use: