if exists(select * from t_CompanySumMoney where f_id='a') then
update t_CompanySumMoney set f_companyMoney=f_companyMoney+ 5.0 where f_id='a';
else
insert t_CompanySumMoney values('a',3);
end if
update t_CompanySumMoney set f_companyMoney=f_companyMoney+ 5.0 where f_id='a';
else
insert t_CompanySumMoney values('a',3);
end if
mysql> ?
update t_CompanySumMoney set f_companyMoney=f_companyMoney+ 5.0 where f_id='a';
else
insert t_CompanySumMoney values('a',3);
end if=====================
应该是 insert into吧,LZ
update t_Compa' at line 1
mySQL
[ELSEIF search_condition THEN statement_list] ...
[ELSE statement_list]
END IFmysql手册的帮助,支持if的
肯定支持,我在存储过程用过
declare iCount int default 0;
select count(*) into iCount from t_CompanySumMoney where f_id='a';
if iCount = 0 then
insert into t_CompanySumMoney values('a',3);
else
update t_CompanySumMoney set f_companyMoney=f_companyMoney+ 5.0 where f_id='a';
end if;
update t_Compa' at line 1
可以多语句执行吧,再说if else应该是一条语句
SQLSERVER的语法翻译成MYSQL的。已经结贴的有个和你问题一样的。搜索一下
-------------
顺便说说,版主啊,那个csdn的搜索可是出名不能用的,还不如用百度搜出来。
select count(*) from t_CompanySumMoney where f_id='a' into @cnt;
if @cnt > 0 then
update t_CompanySumMoney set f_companyMoney=f_companyMoney+ 5.0 where f_id='a';
else
insert t_CompanySumMoney values('a',3);
end if;