array in MySQL

前端 未结 3 1165
庸人自扰
庸人自扰 2021-01-03 07:55

I want to store an array in a record.

Table1:

ID, Name, Friends (friends should be an array)
1, Bill, 2&3
2, Charles, 1&3
3, Clare, 1

I want to

3条回答
  •  温柔的废话
    2021-01-03 08:31

    You might want a comma-separated value, but it's not recommended. Why not use another table for showing relationships?

    Table2
    ----------------------
    PARENT_ID | FRIEND_ID
    ----------------------
    1         | 2
    1         | 3
    2         | 1
    2         | 3
    ----------------------
    

提交回复
热议问题