相関サブクエリの代わりに、2つのテーブル間の結合を使用できます。
SELECT c.id,
u.display_name,
c.comments_count
FROM users u
LEFT JOIN
(
SELECT COUNT(*) comments_count, author_id
FROM cms_comments
GROUP BY author_id
) c
ON c.author_id = u.id
WHERE c.comments_count > 150;
更新に基づいて編集すると、次のようなものを引き続き使用できるはずです。
SELECT c1.cat_id,
c1.category_name,
c1.seo_name,
c2.CountCategoryName
FROM `ccs_coupons` c1
LEFT JOIN
(
SELECT count(category_name) CountCategoryName, category_name,
website_name, description, url_desc
FROM ccs_coupons
GROUP BY category_name
) c2
on c2.category_name LIKE c1.category_name
or c2.website_name LIKE c1.category_name
or c2.description LIKE c1.category_name
or c2.url_desc LIKE c1.category_name
WHERE c1.category_name like 'a%'
ORDER BY c1.category_name ASC
LIMIT $page,$config;
または使用する:
SELECT c1.cat_id,
c1.category_name,
c1.seo_name,
count(c2.category_name)
FROM `ccs_coupons` c1
INNER JOIN ccs_coupons c2
on c2.category_name LIKE c1.category_name
or c2.website_name LIKE c1.category_name
or c2.description LIKE c1.category_name
or c2.url_desc LIKE c1.category_name
WHERE c1.category_name like 'a%'
GROUP BY c1.category_name
ORDER BY c1.category_name ASC
LIMIT $page,$config;