【发布时间】:2011-09-15 07:08:01
【问题描述】:
我正在就以下问题寻求帮助:
我有两张桌子
Table_1 列是itemid、locationid、quantity
Table_2 列是itemid、location1、location2、location3
我想将数据从Table_1(仅quantity 列)复制到Table_2(复制到location1 列)。 itemid 在两个表中都是相同的(Table_1 具有重复的项目 ID)所以这就是我想复制到一个新表并将所有数量保留在一行中的原因,每个位置作为一列。我正在使用以下查询,但它不起作用
INSERT INTO
Table_2(location1)
(
SELECT qty
FROM Table_1
WHERE locationid = 1 AND Table_1.locationid = Table_2.locationid
)
【问题讨论】: