MySQL Common functions

Source: Internet
Author: User

First section: Date and Time functions

1,curdate () returns the current date;
2,curtime () returns the current time;
3,month (d) Returns the month value in Date D, in the range 1~12

SELECT curdate (), Curtime (), MONTH (birthday) as M from t_t;

Section II: String functions

1,char_length (s) calculates the number of characters of the string s;
2,upper (s) to turn all letters into uppercase letters;
3,lower (s) turns all letters into lowercase letters;

SELECT username,char_length (UserName), UPPER (UserName), LOWER (userName) from t_t;

Section III: Mathematical Functions

1,a BS (x) to seek absolute value

SELECT num,abs (num) from t_t;
2,SQRT (x) to find the square root
3,mod (x, y) Seek redundancy

SELECT SQRT (4), MOD (9,4) from t_t;

Section Fourth: Cryptographic functions

1,password (str) password encryption is generally not reversible for the user

INSERT into t_t VALUES (NULL, ' 2013-1-1 ', ' A ', 1,password (' 123456 '));
2,MD5 (str) ordinary encryption irreversible

INSERT into t_t VALUES (NULL, ' 2013-1-1 ', ' A ', 1,md5 (' 123456 '));
3,encode (STR,PSWD_STR) encryption function, the result is a binary number, you must use the Blob Type field to save it;

INSERT into t_t VALUES (NULL, ' 2013-1-1 ', ' A ', 1,md5 (' 123456 '), ENCODE (' abcd ', ' AA '));
4,decode (CRYPT_STR,PSWD_STR) decryption function;

SELECT DECODE (pp, ' AA ') from t_t WHERE id=5;

MySQL Common functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.