Answer the question
In order to leave comments, you need to log in
How to correctly compose a query with a subquery?
Friends. Tell me, what's wrong? The query returns zeros..
You need to get the number of news for each category..
SELECT ct.`id`, (SELECT count(`id`) FROM dle_post ps WHERE ps.category regexp 'ct.`id`' && approve = '1') as allnews_ FROM dle_category ct
Answer the question
In order to leave comments, you need to log in
try like this:
select
ct.id,
count(1) as allnews_
from dle_category ct
left join dle_post ps on ps.id = ct.id
where true
and ps.approve = '1'
group by ct.id
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question