sql 函数

来源:互联网 发布:python微博爬虫实战 编辑:程序博客网 时间:2024/05/08 05:30
1.convert函数
  格式:CONVERT(value, type);
可以转换的类型是有限制的。这个类型可以是以下值其中的一个:
  • 二进制,同带binary前缀的效果 : BINARY   
  • 字符型,可带参数 : CHAR()    
  • 日期 : DATE    
  • 时间: TIME    
  • 日期时间型 : DATETIME    
  • 浮点数 : DECIMAL     
  • 整数 : SIGNED    
  • 无符号整数 : UNSIGNED
    示例: selectconvert(birthDay, DATETIME) from users;

2 if 函数
select IF(age = "9", "8", age) age fromusers;

3 case when
select  case gender when 1 then"男 ”
                               when 2 then "女"
                               else "error" end   gender fromusers; 



原创粉丝点击