我试图从选择查询中插入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
如果我删除插入查询并只运行select,我将得到poolId
和tagId
任何帮助或建议真的很感激
1条答案
按热度按时间xmakbtuz1#
你需要删除
VALUES
子句,因为你实际上没有传递一些值,而是传递了一个SELECT
语句:insert into pool_tags_tag ("poolId", "tagId") SELECT p.id ...