case语法中是否可以使用insert和update,delete语言?
如
select
case when no exists(select * from table1 where table1.no = table2.no)
then
insert table1(v1,v2) select 1,table2.no
else
update table1 set v1 = 1,v2 = table2.no
end
from table2
--不可以,后面必须是一个明确的值,并且必须是唯一
select
case when no exists(select * from table1 where table1.no = table2.no)
then
select table2.no from table2 where 条件1--这里必须select 出来table2.no唯一
else
select table2.no from table2 where 条件2--这里必须select 出来table2.no唯一
end
from table2