[英]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.