我正在尝试运行条件插入语句,但遇到问题。声明如下:
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)
);
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
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)
);
Run Code Online (Sandbox Code Playgroud)
你不能有两个 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));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3213 次 |
| 最近记录: |