问下if then的MYSQL语句问题
if EXISTS(select 1 from codecontrol where codetype='组织结构') then
update codecontrol set MaxCode=MaxCode+1 where CodeType='组织结构';
ELSE
INSERT into codecontrol(MAXcode,dCloseDate,codetype,othercode) values(1,NOW(),'组织结构','00');
end if;
这句话如果放在mysql的存储过程里面运行没问题
然后在查询里面运行就报错
为啥?