Answer the question
In order to leave comments, you need to log in
How to group an array with data?
I retrieved data from the database, and got an array with the following data:
tag | likes
котики | 32
собачки| NULL
котики | 44
попугаи| NULL
собачки| NULL
array(
котики => array(2, 2),
собачки => array(0, 2),
попугаи=> array(0, 1)
)
Answer the question
In order to leave comments, you need to log in
SELECT tag, SUM(likes), COUNT(*)
FROM table_name
GROUP BY tag
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question