【发布时间】:2012-03-09 09:44:45
【问题描述】:
道具 道具ID 道具说明
多对多关系
图片 图片ID 图片描述
Image_has_Prop Prop_PropID Image_ImageID
在我的应用程序中,我需要将数据插入到 Image_has_Prop 中。用户输入 ImageId,然后从显示 PropDescription 字段的 JComboBox 中选择 Prop。我试图弄清楚如何将描述与它的外键联系起来,这甚至可能吗?因为我认为 PropDescription 可能不是唯一的。下面是我的尝试,老实说,使用mysql数据库,我觉得还差得远。
INSERT INTO Image_has_Prop
(Image_ImageID, Prop_PropID)
VALUES
(Select ImageID FRom Image where ImageID ='1', SELECT PropId FROM Prop Where PropDescription = 'Tablets');
【问题讨论】:
标签: mysql sql foreign-keys junction-table