需要在mysql逗号分隔值中最受欢迎的值?

Rav*_*dia 5 php mysql

我的标签表

| id  | tags         
| --- | ------------ 
| 1   | css,html,php 
| 2   | php,java,css      
| 3   | java,c++,ios 
Run Code Online (Sandbox Code Playgroud)

需要出来像

| tags  | tags         
| ---   | ------------ 
| css   |  2  
| php   |  2    
| java  |  1
| html  |  1
| c++   |  1
| ios   |  1
Run Code Online (Sandbox Code Playgroud)

Sou*_*ose 2

不确定您使用的是什么数据库扩展。你可以试试这个——

// 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);
Run Code Online (Sandbox Code Playgroud)

这就像一个算法。用您的代码实现它。