重新设计数据库布局,我遇到了障碍:
现在命名的原始表Items_Old
具有以下 3 列的重要性:
Name | Width | Length
从那以后,我制作了一个新表,名为ItemSizes
:
ID | Width | Length
最后一个叫Items
:
Name | SizeID
我想弄清楚如何从ItemSizes
表中选择 SizeID 到Items
表中
where Items_Old.Name = Items.Name and Items_Old.Width = ItemSizes.Width
AND Items_Old.Length = ItemSizes.Length
我已经能够获得 SizeID 和 Items_Old.Name 的列表,其中包含以下内容:
Select IST.ID , Old.Name
From ItemSizes AS IST, Items_Old AS Old
Where IST.Width = Old.Width
And IST.Length = Old.Length
但是当我尝试类似的东西时:
Insert Into Items
(SizeID)
Select IST.ID , Old.Name
From ItemSizes AS IST, Items_Old AS Old
Where IST.Width = Old.Width
And IST.Length = Old.Length
Where Items.Name = Info.Name
由于第二个我也尝试过的地方,我得到了一个语法错误
Insert Into Items
(SizeID)
(Select IST.ID , Old.Name
From ItemSizes AS IST, Items_Old AS Old
Where IST.Width = Old.Width
And IST.Length = Old.Length) As Info
Where Items.Name = Info.Name
但出现错误near "("