php - I have comma seperated column and need to get most common values from them in mysql -
i have comma separated value in mysql table field , want common value amongst them.
i.e. have table name a
, in there 2 fields id
, available_values
.
id available_values --- ----------------- 1 3,5,7,9 2 3,5 3 5,9
in above example there value 5 exist in rows need value(mean - 5), because available in every records.
please find out solution.
thanks in advance.
best way include table 1 row per id , values. can use regexp
achieve output :
select * table_name available_values regexp concat('(^|,)(', replace(5,',','|'),')(,|$)')
Comments
Post a Comment