Answer the question
In order to leave comments, you need to log in
How to find out how many rows are merged in select inner join with the same parent_id?
father-in-law table
id, price, sum
parent_id, date
select * from t1 inner joun t2 on t1.id=t2.parent_id
id, count, price, sum, parent_id, date, CONT(parent_id)
1, 2, 20, 10, 1 , 1-1-2000, 1
2, 3, 50, 30, 2, 1-1-2000, 1
3, 2, 20, 10, 3, 1-1-2000, 2
4, 3, 50, 30, 3, 1-1-2000, 2
How to correctly count how many rows are merged with the same parent_id - the last column
Answer the question
In order to leave comments, you need to log in
SELECT t2.parent_id, COUNT(*) FROM t1 INNER JOIN t2 ON t1.id=t2.parent_id GROUP BY t2.parent_id
Your query does not concatenate any rows. All parent_ids will be separate strings in the result.
In order for something to start merging, you need to group the rows using group by (in your case, apparently you need to group by parent_id), then you can apply count (*) and it will show the number of merged rows according to the given criterion.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question