[英]Conditional insert statement in postgresql
I am trying to run a conditional insert statement but running to issues. 我正在尝试运行条件插入语句,但遇到了问题。 Here the statement: 这里的声明:
insert into category_content (category_id, content_id, content_type_id, priority) (select 29, id, 1, 1 from article where blog_id = 80)
where not exists(
select * from category_content where category_id = 29 and firstname in (select id from article where blog_id = 80)
);
This is the error I get: 这是我得到的错误:
ERROR: syntax error at or near "where"
LINE 2: where not exists(
^
********** Error **********
ERROR: syntax error at or near "where"
SQL state: 42601
Character: 153
You can't have two where clauses, only one: 您不能有两个where子句,只有一个:
insert into category_content (category_id, content_id, content_type_id, priority)
select 29, id, 1, 1
from article
where blog_id = 80
and not exists(select *
from category_content
where category_id = 29
and content_id in (select id
from article
where blog_id = 80));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.