my tags table
| id | tags
| --- | ------------
| 1 | css,html,php
| 2 | php,java,css
| 3 | java,c++,ios
need out put like
| tags | tags
| --- | ------------
| css | 2
| php | 2
| java | 1
| html | 1
| c++ | 1
| ios | 1
Not sure what DB extension you are using. You can try this -
// Fetch the data by executing-
"SELEC GROUP_CONCAT(tags) tags FROM my_tags";
// Then explode them
$tags = $row['tags'];
$tags_array= explode(',', $tags);
//Count the values
$counts = array_count_values($tags_array);
// Sort
$counts = arsort($counts);
This is like an algorithm. Implement it with your code.
Try this.. Hope it will help.
SELECT `value`,
COUNT(`value`) AS `value_occurrence`
FROM `my_table`
GROUP BY `value`
ORDER BY `value_occurrence` DESC
LIMIT 1;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With