日期函數:
查看當前日期:
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');
?
?
?
?
?
?
?
?
?
?
?
?