Mysql common functions

Source: Internet
Author: User

Mysql common functions

Common functions:

  • Length () indicates the length of the returned bytes.
  • Char_length () indicates the number of returned characters.
  • Rand () indicates the random decimal place between 0 and 1.
  • Round () indicates rounding.
  • Date_add (now (), interval 10 day) indicates the date after 10 days.
  • Date_add (now (), interval-10 day) indicates the date 10 days ago.
  • Date_add (now (), interval 10 minute) indicates the time after 20 minutes.
  • Date_add (now (), interval 10 week) indicates the date after 10 weeks
  • Datediff () indicates the number of days between two dates.
  • Timestampdiff (hour, now (), '2017-01-21 12:10:20 ') indicates that the time difference between two dates is returned.
  • Date_format (now (), '% Y-% m-% d % H: % I: % s') indicates formatting a date and time.
  • From_unixtime () indicates converting a timestamp into a date.
  • Unix_timestamp () indicates converting a date into a timestamp.
  • From_unixtime (timestamp, '% Y-% m-% d % H: % I: % s') indicates converting the timestamp into a date in the specified format.
  • Concat () connection string.
  • Repeat ('abc', 2) indicates that a string is repeated several times.
  • Space (20) indicates the string that generates 20 spaces.
  • Md5 (), sha (), sha1 (), password () indicates the encryption function.
  • Supper () indicates converting the string to uppercase.
  • Lower () indicates converting the string to lowercase.
  • Left () indicates the length of the substring from the left.
  • Right () indicates the length of the substring from the right.
  • Mid () indicates the length of the substring from the specified position. The index starts from 1.
  • Ifnull (expression 1, expression 2) If expression 1 is not empty, expression 1 is displayed; otherwise, expression 2 is displayed.
  • If (expression, result 1, result 2) if the expression is true, result 1 is displayed; otherwise, result 2 is displayed.
  • Uuid () indicates that 36 unique random strings are returned.
  • Format () indicates formatting a number.
  • Inet-aton () converts an IP address string to a number.
  • Inet-ntoa () converts a number to an IP address.

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.