Several useful functions in mysql, useful functions in mysql

Source: Internet
Author: User

Several useful functions in mysql, useful functions in mysql
1. FROM_UNIXTIME
Purpose: display the time stored in INT (11) in MYSQL in the "YYYY-MM-DD" format. Example:

select mtime, from_unixtime(mtime) from topics limit 10;




2. CONCAT (str1, str2 ,...)Purpose: concatenate str1, str2. .. into a string. If any parameter is NULL, the return value is NULL. Example:
update video set playlink = concat(playlink, '&fr=abcd');
Add the fr parameter to all playlinks in the table.
3. CONVERT (value, type );Function: converts a value of one type to another.

There are limits on the types that can be converted. This type can be one of the following values:

-Binary, with the same effect as BINARY Prefix: binary-numeric type, with parameters: CHAR ()-DATE: DATE-TIME: TIME-DATE: DATETIME-Floating Point Number: DECIMAL-integer: SIGNED-UNSIGNED integer: UNSIGNED example: assume there is a money field. To avoid losing the DECIMAL precision, we use varchar to record its value. However, what if we want to compare the size of this field with the number?
select * from bill where convert(money, DECIMAL) > 100;

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.