错误使用多个选择和连接语句将多个数据插入表中

时间:2018-06-05 12:50:13

标签: sql postgresql

我有以下查询将数据插入表中。

INSERT INTO linking (user, relaterd, type, changedate, changeuser, createdate, muser, id, common)
   SELECT map.user, mre.uuid,  'BALL',  TIMESTAMP '2019-11-03 00:00:00.000', 'system',  TIMESTAMP '2019-11-03 00:00:00.000',  'system',  uuid_generate_v4(), mre.uuid
   FROM (SELECT user FROM mapuser v JOIN mct m ON v.uid = m.groep) map
   JOIN (SELECT mr.uuid, mr.number FROM mre mr where mr.type = 'KCT') mre ON mre.number = substring(m.groep, 2, length(m.groep));

我想要列" 用户"," relaterd "和" 共同"由SELECT-JOIN语句填写。列" 相关" 和" 共同"具有相同的值。其他列是常量。

当我执行此查询时,我得到表格的#strong> ERROR MESSAGE :: missing FROM-clause条目" m"。它希望我使用它表格" mct" 的条款,我认为我不需要它,因为加入 mapuser 表。

1 个答案:

答案 0 :(得分:1)

您在m之外没有表(SELECT user FROM mapuser v JOIN mct m ON v.uid = m.groep)

尝试将m替换为map:

substring(map.groep, 2, length(map.groep))

在您的查询中,FROM-clause中只有表map,而mre加入了// webpack.config.js module.exports = { ... entry: { main: ['./index.js'], } } // index.js import 'babel-polyfill' ... 。其他表'别名仅存在于子查询中。