我试过的是:
CREATE TABLE temporary_bundle_wired
AS SELECT * FROM temporary_bundle,wired_items
WHERE temporary_bundle.id = wired_items.id;我有两张桌子:
temporary_bundlewired_items我想创建第三个表,名为temporary_bundle_wired。在这个表中,我想插入temporary_bundle WHERE temporary_bundle.id = wired_items.id中的所有行(及其列和字段)
一旦我将这些记录移到tempoary_bundle_wired中,我还想将它们从tempoary_bundle_wired中删除。
我尝试过的查询返回:
duplicate column name Id
发布于 2017-09-04 19:39:16
我尝试过的查询返回:
duplicate column name Id
以上错误明目张胆地表示您有重复的列。正在创建的新表中的列名(id)在两个旧表的公共属性(temporary_bundle.id和wired_items.id)之间发生冲突。
确保两个表之间没有其他公共属性。如果存在,则在插入之前从任何一个表中将它们化名。
如果其他人不起作用,就试试这个。
CREATE TABLE temporary_bundle_wired
AS
SELECT
t.id as id, user_id, base_item, extra_data, x, y, z, rot, wall_pos, limited_number, limited_stack, sandbox -- and all other attributes you want
FROM temporary_bundle t, wired_items w
WHERE t.id = w.id;删除-这是一个不同的查询在一起。
DELETE from temporary_bundle t WHERE t.id = (select id from wired_items);发布于 2017-09-04 19:24:17
一个问题确实是,两个表之间的id是相同的。其他列也可能是这样,但是如果id是唯一的问题,那么使用using子句:
CREATE TABLE temporary_bundle_wired AS
SELECT *
FROM temporary_bundle JOIN
wired_items
USING (id);https://stackoverflow.com/questions/46042375
复制相似问题