MySQL 临时变量取值三例

来源:互联网 发布:网络教育统考严吗 编辑:程序博客网 时间:2024/06/06 13:07

例子1:常规用法

DECLARE iSystemTypeId INT;
set iSystemTypeId  = NULL;
select SystemTypeId into iSystemTypeId from B_SystemType  where os = Aos;


 

例子2:trigger中用的多
DECLARE lockTime datetime;
set  lockTime=(select lockTime from ccmUsers where name=myuser);


 

例子3:临时变量用户
set @mysum=0;                                  
select @mysum:=COUNT(*) from mendpinfo where ipaddr = rvIpaddr;


原文地址:http://blog.csdn.net/panpanxj/article/details/2729791

0 0