I need to store a set of values e.g. A, B, C under say country column of a SQL ta开发者_运维技巧ble. Coould you let me know if there is any data type that is able to store a set of values in a SQL table column?
Thanks in advance.
To store a set, you would normally create a second table with a foreign key relation.
MySQL also has some functions to store a comma-separated list in a column, like find_in_set. This is considered bad form, though you might choose it for a quick one-time hack.
EDIT: For some reason Bakkal deleted his answer. His answer was new to me and I thought it was rather interesting, so I'll copy it here:
https://dev.mysql.com/doc/refman/5.7/en/set.html
This allows you to store a small set (less than 65 items) in a column.
That's probably bad database design.
From what I can see you should create a new table OR if you know you'll only have up to 3 countries, have 3 separate columns
精彩评论