Mysql, storing multiple value in single column from another table

前端 未结 3 465
攒了一身酷
攒了一身酷 2020-12-15 10:23


Bear with me, im really bad at explaining thing and i dont even know an appropriate title for this problem
Ok guys i have this problem
I already have one table

3条回答
  •  时光说笑
    2020-12-15 11:26

    Create a many-to-many link table:

    combo_id    meal_id
    1           1
    1           4
    1           7
    1           9
    2           2
    2           5
    2           8
    3           3
    3           5
    3           6
    3           9
    

    To select all meals for a given combo:

    SELECT  m.*
    FROM    combo_meal cm
    JOIN    meal m
    ON      m.id = cm.meal_id
    WHERE   cm.combo_id = 1
    

提交回复
热议问题