set @userName='小可爱';
set @userName=:'玛卡巴卡';
select @userName as '名称';
select @userName:='唔西迪西' as '赋值并查询,先赋值,再查询'
set @x=5,@y=7,@dx=3.1425,@dy=6.678;
select @x + @y as '四则运算';
select @x - @y as '四则运算';
select @x * @y as '四则运算';
select @x / @y as '四则运算';
select @x % @y as '四则运算';
set @result1= @dx + @dy;
set @result2= @dx - @dy;
set @result3= @dx * @dy;
set @result4= @dx / @dy;
set @result5= @dx % @dy;
select @result1,@result2,@result3,@result4,@result5;
select round(@result3,2)
#关系运算符与逻辑运算符
set @x=7,@y=5;
select @x>=@y as 'TRUE',@x<=@y AS 'FALSE';
SELECT @x=@y;
select true AND FALSE;
SELECT FALSE OR TRUE;
set @userName='龙姑娘';
set @age=17;
select * from student where userName=@userName or age=@age;
set @userName1='龙姑娘';
set @userName2='王语嫣';
set @userName3='赵灵儿';
select * from student where userName in(@userName1,@userName2,@userName3)
select @@MAX_CONNECTIONS;
SELECT @@BINLOG_CACHE_SIZE;
SELECT @@VERSION AS '版本'
定义变量及运算
最新推荐文章于 2024-09-27 16:27:44 发布