开发者

creating a list in MySQL

I want to create a MySQL database with one column containing a list(variable in size for different entries). I also have to allow ent开发者_开发问答ries to be added to that list later. What is the way to do this ?


The way this is typically done is to create a separate column that groups the items together:

list_id, value
1, a
1, b
1, c

2, e
2, f

SELECT value FROM table WHERE list_id = 1 will return three rows: (a, b, c)

Adding a new value x into list_id 2 would be something like this:

INSERT INTO table VALUES(2, 'x')

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜