Mysql学习2

上一篇 / 下一篇  2016-01-27 14:55:39 / 个人分类:测试技术

存储过程和常用函数:

1、在select查询中设置变量:select sum(ifnull(cash,0)) into @column1 from table1 where ......【select .. into】

2、存储过程的“return”【mysql中没有return,用标签+leave可代替return】
create procedure pro1
lable1:
begin
.....
......
leave label1;
end

3、有自增列id时,max和min函数也是常用select max(Id) into @maxid from table2

4、CAST()和CONVERT(),就是CAST(xxx AS 类型), CONVERT(xxx,类型)。可以转换的类型是有限制的。这个类型可以是以下值其中的一个: 
二进制,同带binary前缀的效果 : BINARY   
字符型,可带参数 : CHAR()    
日期 : DATE    
时间: TIME    
日期时间型 : DATETIME    
浮点数 : DECIMAL     
整数 : SIGNED    
无符号整数 : UNSIGNED
select * from table1 where Id = @id and flag = 0 and cast( charcolumnum as unsigned) < @max

TAG:

 

评分:0

我来说两句

Open Toolbar