Mysql group through comma separated values

I have mysql table comments in this table, the field are tags, and all tags are separated by comma, e.g.

Comment table

Name Reply Tags ab new,old,facebook,fb bd water,faebook,wall br wall,php,fb cq name,facebook,email ay weather,cold,old aw twitter,next,pet,fb 

I need to get the most used tag in this table with mysql query.

+6
source share
1 answer

I think the best approach is to use a separate table for tags and the relationship between tags and your table (i.e. CommentTags), this will allow you to quickly find those comments that use any speciffic tag, make statistics, etc. . With your current approach, you end up using line splitting for each line.

Now, if you are stuck in your current approach, here , this is a question about line splitting, which might be useful. But I predict that many users complain about performance ...

+3
source

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


All Articles