Common functions
arithmetic Functions
I believe you can understand, so the above is not too much explanation
And then there's the between and: the one that's missing from the front.
Indicates whether 10 is between 0 and 20 and returns 0 if it returns 1
Date Function
this should be a little attention to the parameters, the first is the starting date, interval is fixed, 2 is the number of days to add, the following day is the unit, or it can be week,year
Information Functions
Aggregation Functions
The above because I this test database under the table does not have very good data, so the operation to get the results feel very strange, you forgive me, you know how to use it
Cryptographic Functions
The above two kinds of cryptographic functions, I personally feel is not very safe.
Because MD5 although the encryption operation is not reversible (can not be reversed with encrypted data), but the encrypted data is regularly traceable, do not believe you can operate on your own computer to see the encryption "testing" see if it is the same as mine, So as long as you can md5 encrypted out of all the data into a database, and then directly one of the decoding on the line. And although the password method can be a case,
However, for general operations, using these two cryptographic functions is sufficient.
Custom functions:
1) Requirements for custom functions:
- Parameters can have 0 or more
- The return value must have only one
There can be no definite connection between the parameter and the return value, all functions have a return value, but the parameters are not necessarily.
The function can return any type of data, and it can also accept any type of data as a parameter
2) function Body of the custom function:
3) Example:
A: Without parameters
- Returns specifies the data type of the function return value
- Return returns a specific value/value variable
- The function name must be followed by parentheses, or the error
B: With parameters:
C: Create a compound function
Current table information:
Create:
The error here is because MySQL defaults to end with a semicolon, then the data will not be inserted into the table will end
The MySQL default terminator can be changed from semicolon to//by using the
Create and view the data again:
D: Delete a custom function
MySQL Database (6)--mysql common function functions/custom functions