A few useful functions in MySQL

Source: Internet
Author: User

1. From_unixtime
effect: Displays the time in MySQL as an int (11) in the "YYYY-MM-DD" format. Example:
Select Mtime, From_unixtime (mtime) from topics limit 10;




2. CONCAT (str1,str2,...) Function: Will str1, str2 ... Connect as a string. If any one of the arguments is NULL, the return value is null. Cases:
Update video Set playlink = Concat (Playlink, ' &FR=ABCD ');
All the tables in theAdd a fr parameter to the Playlink
3. CONVERT(value, type); function: Converts a value of one type to another type

There is a limit to the types that can be converted. This type can be one of the following values:

-binary, with binary prefix effect: binary-character type, parameter: CHAR ()-Date: Date-time: Time-datetime type: DATETIME -Floating point: Decimal-integer: Signed-unsigned integer: UNSIGNED example: Suppose there is a money field, in order not to lose the precision of its decimals, we use varchar to record its value. But then there is a problem, what if you want to compare the size of this field with the number?
SELECT * from Bill where to convert (money, DECIMAL) > 100;

Several useful functions in MySQL

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.