Query with multiple values in a column

后端 未结 4 1311
忘了有多久
忘了有多久 2020-11-22 03:14

I have a table like:

id     name            children
1      Roberto         Michael,Dia
2      Maria           John,Alex
3      Mary            Alexandre,Dia         


        
4条回答
  •  无人共我
    2020-11-22 03:46

    You should split the data into two tables.

    the first would look like this

    ID    Name
    1     Roberto
    2     Maria
    3     Mary
    

    And the second like this

    ParentId     child
    1            Michael
    1            Dia
    2            John
    2            Alex
    

    and so on.

    then you could do the query you want without having to worry about like and your data is much more useable

提交回复
热议问题