#声明变量
#标识符不能以数字开头
#自能使用-或$符号不能其他符号
#不能使用系统关键字
set @userName ='刘德华';
select @userName:='刘青云';#将赋值与查询结合
#查询变量/使用变量 匿名的时候建议加上as
select @userName as '读取到的userName 变量值';
#整数类型与浮点型测试
set @x=5,@y=7;
select @x + @y as '5+7的结果';
set @dx=6.9,@dy=2;
select @dx + @dy;#浮点数计算异常显示无限000
# 去零操作 重新赋值即可以做到
set @result=(select @dx + @dy);
select @result;
# 通过修改变量的方式进行精准查询
set @cityName1='kabul';
set @cityName2='Qandahar';
set @cityName3='Maastricht';
select * from city where `name`=@cityName1;
select * from city where `name`in(@cityName1,@cityName2,@cityName3);
select @cityNAme;