我试图从选择查询插入
postgresql
表,这里我有多个连接,我成功地设法从选择查询中获取数据,但是当我运行insert
时得到语法错误ERROR: syntax error at or near "select"
下面是我试过的
insert into pool_tags_tag ("poolId", "tagId") values (
select p.id as "poolId", t3.id as "tagId" from tag t3, pool p where t3.title in
(select q.topic as "questionTopic" from question q
join question_experience qe on qe."questionId" = q.id
join "question_jobRole" qjr ON qjr."questionId" = q.id
join tag t on t.id = qjr."tagId"
join tag t2 on t2.id = qe."tagId"
where t.title = 'FE' and t2.title = 'FRESHER')
and p.id=144 limit = 1) ON CONFLICT ("poolId", "tagId") DO nothing
如果我删除插入查询并只运行选择我得到
poolId
和tagId
真的很感激任何帮助或建议
您需要删除
VALUES
子句,因为您实际上并没有传递一些实际值,而是传递了一个 SELECT
语句:
insert into pool_tags_tag ("poolId", "tagId") SELECT p.id ...