Home > Mobile >  Getting multiple rows data field 2 based on single value from field 1 in sql
Getting multiple rows data field 2 based on single value from field 1 in sql

Time:01-16

I have a table from which I want to return data based on a distinct name column with correspondent multiple row values from the options column table.

Table data:

here

Looking Output:

Name   Options
-----------------------------------
bread  white, brown 
jam    stawberry, apple, mangoe

Any suggestion or best advice is apprecheated

CodePudding user response:

This question is asked every day without fail, you would simply do

select name, group_concat(options separator ', ')
from t
group by menu_id, name
  •  Tags:  
  • Related