LMSouq
database Open

How to store arrays in MySQL?

TO
tonga
1 month ago
3 views
Problem Description
I have two tables in MySQL. Table Person has the following columns: id | name | fruits ---|------|------- The `fruits` column may hold null or an array of strings like ('apple', 'orange', 'banana'), or ('strawberry'), etc. The second table is Table Fruit and has the following three columns: fruit_name | color | price -----------|--------|------ apple | red | 2 orange | orange | 3 -----------|--------|------ So how should I design the `fruits` column in the first table so that it can hold array of strings that take values from the `fruit_name` column in the second table? Since there is no array data type in MySQL, how should I do it?

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base