Need the most popular mysql comma value?

table of my tags

| id | tags | --- | ------------ | 1 | css,html,php | 2 | php,java,css | 3 | java,c++,ios 

need to put as

 | tags | tags | --- | ------------ | css | 2 | php | 2 | java | 1 | html | 1 | c++ | 1 | ios | 1 
+5
source share
3 answers

Not sure which database 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 similar to an algorithm. Contribute this with your code.

+2
source

Try it. Hope this helps.

 SELECT `value`, COUNT(`value`) AS `value_occurrence` FROM `my_table` GROUP BY `value` ORDER BY `value_occurrence` DESC LIMIT 1; 
+1
source

This may help: select group_concat(tags) from tags group by tag;

+1
source

Source: https://habr.com/ru/post/1243105/


All Articles