Built-in functions in MySQL

Source: Internet
Author: User
Tags date now month name

The built-in functions in MySQL are used in the select statement and the update delete function in the where order by hacing clause. The field name can be used as a field. The value of the variable is the record of each row corresponding to the column. I. functions used in string functions in php. Most of mysql also provides www.2cto.com 1, CONCAT ("string", field ,........): Concatenates the input parameter into a string, and returns the connected string concat ('afd', 'bb '). The returned values include adfbb 2, INSER (str, x, y, insert ): replace string 'str' and 'x' with string 'insert'. 3. LOWER (str) UPPER (str): Convert string to uppercase or lowercase. 4. LEFT (str, x) RIGHT (str, x): returns the leftmost x characters and rightmost x characters, respectively, if the second parameter is null, return null 5, LPAD (str, n, pad) RPAD (str, n, pad ): pads str leftmost and rightmost with string pad until the length is n characters 6, TRIM (str) LTRIM (str) RTRIM (str) // remove the spaces on both sides, left, and right of the string. 7. replace (str, a, B ): use string B to replace the values of 8, strcmp (s1, s2) of all strings a in str: Compare the ASC size. If s1 is smaller than s2,-1 is returned, if s1 is greater than s2, 1 is returned. If s1 is equal to s2, 0 9 and substring (str, x, y) are returned. the return value is a string of y String Length starting from position x in str. 2. Value Function www.2cto.com ABS (x): returns the absolute value of x, ceil (x): returns the smallest integer greater than x, 2.1, 2.5, 2.9, and returns 3, 1, and returns the Sino-French floor (x ); returns the maximum integer less than x 2.1 2.5 2.9. returns the modulo rand (): Random Number round (x, y) between 0 and 1 of x/y): returns the value of truncate (x, y) rounded to y decimal places in parameter x. returns the result of truncate (1.239, 2) truncated to y decimal places in number x) returns the date function 1.23. When the php time stamp is used to complete the curdate (): return date now (): return date time curtime (): return time unix_timestamp (now ()); returns the unix timestamp from_unixtime (1231314); returns the timestamp www.2cto.com week (now (); year (now ()); Hour (curtime (); minute (curtime (); monthname (now (); month name date_format (now (), "% Y-% m-% d % H: % I: %") 4. process control function if (value, t, f); select if (field> 300, 'v1 ', 'v2') from; if the condition is true, v1 is returned. Otherwise, v2 ifnull (value1, value2) is returned. If value1 is not null, value1 is returned. If value1 is null, value is returned; case when [value1] then [result] ...... Else [default] end case when then else end // select case when salary <= 3000 then 'low' else 'hei' end from ...; 5. Other functions: www.2cto.com database () Current database verdion () current version user () current user inet_aton (192.168.1.1); Return IP address order inet_ntoa (3232235777 ); return the ip address md5 () according to the network address order; return the encrypted string author liu86th

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.