
declare @email char(100) set @email='1028125449@qq.com'
declare @sql varchar(8000) set @sql='select top 5 * FROM Buy,User_Buy,GoodsType where Buy.BuyId=User_Buy.BuyId
and Buy.GoodsTypeId=GoodsType.GoodsTypeId and Buy.BuyId not in (select top '+cast((2-1)*5 as varchar(20))+
' Buy.BuyId FROM Buy,User_Buy,GoodsType where Buy.BuyId=User_Buy.BuyId and Buy.GoodsTypeId=GoodsType.GoodsTypeId
AND User_Buy.UserId=(select UserId from UserInfo where UserEmail='''+@email+''') order by BuyTime desc) and
User_Buy.UserId=(select UserId from UserInfo where UserEmail='''+@email+''') order by BuyTime desc ' exec(@sql)
mysql中变量不用事前申明,在用的时候直接用“@变量名”使用就可以了。第一种用法:set @num=1或set @num:=1//这里要使用变量来保存数据,直接使用@num变量
第二种用法:select @num:=1或 select @num:=字段名 from 表名 where ……
注意上面两种赋值符号,使用set时可以用“=”或“:=”,但是使用select时必须用“:=赋值”
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)