1mysql变量的浮点数问题处理
sql
# mysql变量的浮点数问题处理
set @dx=3.14,@dy=3.25;
SELECT @dx+@dy=3.25;
SET @result=@dx+@dy;
SELECT @result;
MySQL浮点数计算显示异常,会有很多0出现
2mysql利用变量进行查询操作
sql
# mysql利用变量进行查询操作
set @cityname='Haarlemmermeer';
SELECT * FROM city WHERE `name`=@cityname;
# 多个结果查询
set @cityname='Haarlemmermeer,Zoetermeer,Emmen';
SELECT @citynames;
SELECT * FROM city WHERE `name` in (@citynames);
set @cityname1='Haarlemmermeer';
set @cityname2='Zoetermeer';
set @cityname3='Emmen';
SELECT * FROM city WHERE `name ` in (@cityname1,@cityname2,@cityname3);