-
算術函數(shù)
-
ABS--絕對值
abs(數(shù)值)
select m,abs (m) as abs_col from 表名;
-
mod--求余
mod(被余數(shù),除數(shù))
-
round--四舍五入
round(對象,保留的小數(shù)的位數(shù))
-
字符串函數(shù)
-
||--拼接
str1 || str2
在mysql中是concat(字符串,字符串,字符串)
-
length()--字符串的長度
-
lower()--小寫轉換
-
upper()--大寫轉換
-
replace(用來替換的字符串,替換前的字符串,替換后的字符串)--字符串的替換
-
substring(用來截取的字符串 from 開始的截取的字節(jié) for 截取多少字節(jié))--字符串截取
-
日期函數(shù)
-
current_date--當前日期
select current_date;
-
current_time--當前時間
select current_time;
-
current_timestamp--當前日期和時間
select current_timestamp;
-
extract(日期元素 from 日期)--截取日期元素
extract (year from current_timestamp) as year;
-
轉換函數(shù)
-
cast(轉換前的值 as 想要轉換的數(shù)據(jù)類型)--類型轉換
select cast('0001' as integer) as int_col;
結果為1
-
coalesce(數(shù)據(jù)1,數(shù)據(jù)2,數(shù)據(jù)3,……)--將NULL轉換為其他值