0

I have menu_master table like this

id    name     holder
1     a        1,2,4 
2     b        49,4

In the output i only want 1,2,4,49

SELECT GROUP_CONCAT(holder)  
FROM menu_master

If I am using group_concat it gives me all result like 1,2,4,49,4.

dpapadopoulos
  • 1,834
  • 5
  • 23
  • 34
Vipul sharma
  • 1,245
  • 1
  • 13
  • 33
  • The first step is to break these comma-separated lists into a dependent table in which you store one integer per row. This is a problem best solved by normalizing your database. – Bill Karwin Feb 14 '19 at 07:39
  • While a comma separated list is virtually never a good idea in a database, if the possible values of holders are stored in a table, you could do a join to that table based on FIND_IN_SET() to extract the individual values, and then use GROUP_CONCAT(DISTINCT....) with those values. But not likely to perform well. – Kickstart Feb 14 '19 at 09:06

0 Answers0