I. Overview
Function: A similar procedure in java
Benefits: improve reusability and hide implementation details
Call: select function name (argument list);
Second, the one-way function
1, character function
concat :连接 concat(last_name,first_name);
substr : intercepting substring substr (str, start1) substr ( str, start1, length) from a start position Start
Upper : variable capital
Lower : to lower case
the replace : Replace
length : Get byte length
the TRIM : a space before and after the go
LPAD : left padding
RPAD : right padding
InStr : Gets the index of the first occurrence of the substring
2, Mathematical Functions
Ceil : improvement ToSei
round : rounding
MOD : modulo
Floor : rounding down
TRUNCATE : truncates
RAND : acquiring a random number between 0 and 1 return the fraction
3, date function
now : returns the current date + time
year : the return of
month The : Returns the month
Day : Day return
the DATE_FORMAT : Converts a date to a character
CURDATE : returns the current date
STR_TO_DATE : Convert a character to date
curtime : Returns the current time
hour : hour
minute : minutes
SECOND, : s
DATEDIFF : Returns the number of days between two dates
MONTHNAME : Returns the month in English form
4. Other functions
Version : The current version of the database server
database: the currently open database
user: The current user
password : ( 'character'): Returns the character code in the form of
md5: ( 'character'): Returns the encrypted form of the character md5
5, the flow control function
① IF (conditional expression, expression 1, expression 2) : If the condition expression is established, the expression returns 1, otherwise it returns an expression 2
②case Case 1
case variables or expressions or fields
when the constant value 1 then 1
2 then a constant value when 2
...
else the value of n
end
③case Case 2
case
value 1 when condition 1 then
when condition 2 then the value 2
...
else the value of n
end
Third, the group function
1 classification
max : maximum
min : minimum value
sum: 和
avg: 平均值
count: 计算个数