赞
踩
- BEGIN
- declare phonenum VARCHAR(32) ;
- SELECT phonenumber INTO phonenum FROM A WHERE phonenumber = `p_phonenumber` ;
-
- if phonenum is NULL then
- INSERT INTO A (phonenumber ,isselect) VALUES (`p_phonenumber`,`p_isselect`);
- else
- UPDATE A SET isselect = `p_isselect` WHERE phonenumber = `p_phonenumber`;
- end if;
-
- END
A表结构:
需要注意的是:
1.用into将select出来的值赋给declare的变量
2.if判断如果是非空的可以用=,如果是数字还可以> 、<,但是如果像判断是null ,就要用 xxx is null 了
3.注意各个句结束时别丢分号
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。