列中的多个值 [英] Multiple values in a column
本文介绍了列中的多个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一张名为details的表。它有3个字段vendorID,itemID和ItemName。我需要为特定项目添加多个供应商。例如:
供应商ID:1,2,3
ItemID:1
ItemName:abc
I需要在我的表中存储上述模型中的值。
请帮助我。
Hi,
I have a table named details. It has 3 fields vendorID,itemID and ItemName. I need to add more than one vendor for a particular item. For example:
vendor ID:1,2,3
ItemID:1
ItemName:abc
I need to store values in my table in the above model.
Please help me.
推荐答案
不要。
这是一个非常糟糕的主意,你将不得不做很多工作来使用这些信息 - SQL不能在列中存储多个数值,所以你必须将它存储为逗号分隔的字符串:这意味着它根本不与实际供应商直接相关。
相反,添加另一个将ItemID与VendorID相关联的表,并向其添加三行。
Don't.
It's a very bad idea, and you will have to do a heck of a lot of work to use the information later - SQL can't store more than one numeric value in a column, so you would have to store it as a commas separated string: which means it doesn't relate directly to the actual vendors at all.
Instead, add another table which relates ItemID to VendorID, and add three rows to that.
这篇关于列中的多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文