1.字符字节长度
length("张三") 4
char_length("张三") 2
length("zs") 2
char_length("zs") 2
2.字段字符截取函数
select substr(center,1,instr(center,',')-1) from test;
select substr(center,instr(center,',')+1) from test;
3.right函数
select right(fields,1) from test;
4.replace函数
select replace(fields1,'w','W') from tablename
5. substring_index函数
select substring_index(fields,',',1) from tablename;
select substring_index(fields,',',-2) from tablename;
6. ifnull
select ifnull(count(1),0) from tab1;
7.数据类型转换函数
select convert("100",signed);
select cast("100" as signed);
select cast("100" as decimal);
8.字符串类型时间转时间类型时间函数
select str_to_date(str_date,'%Y%m%d%H%i%s');
9.获取当前时间函数
select current_timestamp();
10.格式化时间函数
select date_format(current_timestamp(),'%Y%m%d%H%i%s');
11.计算两个日期格式时间之间的差
select timestampdiff(minute,date1,date2);
12.整除函数
select 12.5 div 3;