日期函数:
查看当前日期:
select current_date();
查看当前时间:
select current_time();
查看当前时间戳:
select current_timestamp();
计算两个日期的差值:
select datediff(date1,date2);
当前的日期时间:
select now();
对日期天数加减:
select date_add(date1,day);//date1加上day
select date_sub(date1,day);//date1减去day
字符串函数:
返回查找字符的起始位置:
select instr(字符串1,子字符串);
//返回找到的子字符串在字符串中的起始位置
字符拼接:
select concat(str1,str2);
字符转换大小写:
//小写转大写
select ucase(str);
//大写转小写
select lcase(str);
从str中的左边去size个字符
select left(str2,size);
将str中用str1替换字符串str中的str2
select replace(str,str2,str1);
比较两个字符串的大小:
select strcmp(string1,string2);
其他函数:
查询当前用户:
select user();
显示当前正在使用的数据库:
select database();
对用户进行加密:
select password('root');