关于SQL 插入数据 写一个IF语句

2024-12-15 23:39:16
推荐回答(3个)
回答1:

if exits (select * from Customer where Customer_name='张三')
begin
update Customer
set Customer_name='张三'
where
end
else
insert into "Customer" (Customer_name) values ('张三')

回答2:

declare
v_num number :=0;
begin
select count(*) into v_num from Customer where xxx(条件);
if v_num>0 then
update......
else
insert......
end if;
commit;
end;

回答3:

使用merge试试