[英]Insert with if condition
我需要创建一个执行此工作的sql语句:假设我有两个包含整数字段的表A和B。 我要实现的是:
if (!(C is contained into A)) insert C into B
我正在使用SQLite。 感谢帮助
实际上,在您的特定情况下,它可能就像
insert into B (c_value) select c_value from A where c_value = @your_c_value_here
查看INSERT语句
抱歉,我没有注意到您的问题中对C的否定,我有另一种选择
with temp_val as (select @your_val_goes_here as val) insert into b select val from temp_val where not exists (select 1 from a where c = val)
看看这个小提琴
[英]SQL Insert - Only insert on this condition
[英]IF condition for INSERT AND UPDATE in SQL
[英]Prevent insert if condition is met
[英]Insert row with a condition
[英]Insert query with condition
[英]How to INSERT based on a condition?
[英]How to add a condition for INSERT INTO
[英]insert values in table by condition
[英]SQL: Update and Insert with condition
[英]SQL query to Insert on Condition
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.