database - Why ENUM does not store multiple values in MySQL? -
i want use enum feature in table using mysql.
i have created table tbl_test having id primary key , enum_col field enum data type.
create table tbl_test( id int not null auto_increment, enum_col enum('a','b','c') not null, primary key ( id ) );
when try store single enum value, got inserted when try store multiple enum values throws sql error.
error:
data truncated column 'enum_col' @ row 1
single enum value (correct):
insert tbl_test(id, enum_col) values(1, 'a');
multiple enum values (failed):
insert tbl_test(id, enum_col) values(2, 'a,b');
any idea store multiple values in enum data type ?
that because can store 1 value in , in fact absolutely should store 1 value in whatever type of column.
use seperate table. can store values multiple records. example:
tbl_test -------- id | name 1 | test_x 2 | test_y 3 | test_z tbl_test_enums -------------- test_id | enum_value 1 | 1 | b 2 | 3 | c
Comments
Post a Comment