MySQL Development basic Series 7 process functions and other functions

Source: Internet
Author: User
Tags md5

I. Process functions

--Create a table to describeCREATE TABLESalary (UserIDINT, salaryDECIMAL(9,2));INSERT  intoSalaryVALUES(1, +),(2, -), (3, the),(4,4000),(5, the), (1,NULL);SELECT *  fromSalary

1. if (value,t,f) more than 2000 of the use of high, otherwise with low

SELECT IF (Salary> ,'high','low'   from Salary

2. Ifnull (VALUE1,VALUE2) The following statement replaces the null value 0

SELECT Ifnull (Salary,0 from salary;

3.case when ... To achieve high and low pay

SELECT  Case  whenSalary<= -  Then ' Low'  whenSalary>=2001  andSalary<=4000  Then'Middle' ELSE ' High'  END  fromSalary

Two. Other common functions

SELECT DATABASE() as 'Database name', VERSION () as 'Database Version',USER() as 'Current user name', Inet_aton ('192.168.1.1') as 'IP bytes', Inet_ntoa (3232235777) as 'IP byte to IP'

2. PASSWORD returns the encrypted character, typically used to set the password of the system user

SELECT PASSWORD ('123456')

3. MD5 (STR) encryption for general application data

SELECT MD5 ('123456');

MySQL Development basic Series 7 process functions and other functions

Related Article

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.