this question might have been asked before, but I could not find. because I was not able to ask correctly all situations. so pardon me if it is a repeated question.
I have 2 tables:
tb1 - categories
tb2 - tasks
I want to select all tasks and quantity of tasks by each category.
What I did is this:
SELECT category_id, category_title,
(SELECT count(task_id) FROM tasks_of_app WHERE category_id ) AS counted_tasks
FROM categories_of_app
but I get all tasks' quantity for each category.
I can't use WHERE because there is not input param.
please, guys help out or tell what book to read to be able to make such kind of queries.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…