#MySQL 变量的定义与使用
#一、标识符命名规范
set @userName="小可爱";
select @userName as '结果名称';
select @userName:='海绵宝宝'as'赋值查询名称';
set @x=5,@y=7;
select @x+@y as'加法运算',@x-/@y as'减法运算',
@x * @y as'乘法运算',@x / @y as'除法运算';
select @x < @y as'大小判断';
select @x >= @y;
select TRUE or false;
set @citName='Rotterdam'
select * from city where `Name`=@cityName;
set @ cityName1='Rotterdam';
set @cityName2='Zaanstad';
set @cityName3='Zwolle';
select * from city where `Name`in(@cityName1,@cityName,@cityName3);
#浮点数0处理
set @dx=0.11,@dy=55.5;
select @dx +@dy;
set @result=@dx + @dy;
select @ result;
MySQL 变量的定义与使用
最新推荐文章于 2024-09-15 20:24:46 发布