MySQL-Single-line function

Source: Internet
Author: User

Casing control functions

SELECT LOWER (' hellowrold'UPPER('HelloWorld');

Character control functions

SELECT REPLACE ('abcdababab','P','m');

Replace the character p in "Abcdababab" with M;

SELECT TRIM ('from');

Remove the spaces on both sides.

SELECT Ten,'-'*') from Employees

Lpad:salary characters are not enough 10, add '-' to the left to 10 characters;

Rpad:salary the character is not enough 10, add ' * ' to the right to gather 10 characters;

SELECT INSTR ('HelloWorld'P');

The query character ' P ' in the HelloWorld position;

SELECT LENGTH ('helloworl');

Returns the ' helloworl ' character length;

SELECT SUBSTR ('HelloWorld',2,5);

Starting from the second position of ' HelloWorld ', intercept 5 characters;

SELECT ROUND (123.4562ROUND(123.5560ROUND(153.456- 2);

Rounded

SELECT TRUNCATE (123.4562TRUNCATE(123.5560TRUNCATE(153.456-  2);

truncated after decimal point;

SELECT MOD (8);

Redundancy operation;

Check all employee information, if department number is 10,
--Print 1.1 times times its salary, department number 20th, print 1.2 times times its salary, and 30th department prints 1.3 times times its wages,
--the other prints 1.4 times times their wages.

SELECTemployee_id, last_name, salary, department_id, Casedepartment_id
when Ten ThenSalary* 1.1 when - ThenSalary* 1.2 when - ThenSalary* 1.3ELSESalary* 1.4END"New_salary";

condition judgment;

MySQL-Single-line function

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.