MySQL function
Description: Mathematical functions, String functions, date-time functions, conditional judgment functions, System information functions, cryptographic functions, etc.
1. Mathematical Functions
2. String Functions
3. Date Time function
4. Conditional Judgment Function
A) IF (expr, V1, v2)
Returns v1 If the expression expr is true ,otherwise returns v2
Example: SELECT ID, age, IF (age>18, ' OK ', ' NO ') from table1;
B) ifnull (v1, v2)
if the value of V1 is empty, V2 is returned
Example: SELECT ID, ifnull (email, ' is NULL ') from table1;
C) case
<when expression 1 then v1>
[When expression 2 then v2]
... ...
[When expression n then vn]
[ELSE DEFV]
END;
5. System Information Function
6. Cryptographic Functions
A) One-way encryption
PASSWORD (' string ');
Used for encrypting passwords and can only be encrypted and not decrypted.
B) MD5 (' string ')
that is used to extract files. MD5
C) symmetric encryption
Encoed (' string ', ' password ') encrypt string
Dencoed (' encrypted string ', ' password ') decrypts the string
7. Other Functions
A) Format function
FORMAT (X, Y)
Digital X Keep Y bit after decimal point
B) in-process conversion
BIN (X) : converting to binary
Hex (X): Convert to Hex
OCT (X): converting to octal
CONV (x, F1, F2): converts X from F1 into F2 Binary
C) IP address Translation
Inet_aton (IP): points converted to UINT32
Inet_ntoa (N):UINT32 Conversion to electrical Division
D) Locking
GET_LOCT (name, time): Locked, name is the name of the lock .
IS_FREE_LOCT (name): Unlock
F) Repeat
BENCHMARK (n, expression ): expression repeats n times
G) Changing the character set of a string
H) Change the type of the field
MySQL function (take a look and look at it carefully)