MySQL 临时变量取值三例

例子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

你可能感兴趣的:(mysql)