MySQL Data character connection function concat

Source: Internet
Author: User

CONCAT () is a string concatenation function
Replace () is a string substitution function

CONCAT (parameter 1, parameter 2,...)

CONCAT (String, FROM_STR,TO_STR)
Returns the string str, where all occurrences of the string from_str are replaced by string to_str.


A derivative function is Concat_ws (separator,string1,string2,...)

The difference between this and concat is that after the connection, there is a separator character separator at the junction. For example:

Update users set HOMEDIR=CONCAT_WS (´/´,´/data/disk1´,´part1´,´user1´) where Userid=´user1´;

The result is User1 's Homedir=´/data/disk1/part1/user1´.


CONCAT (STR1,STR2,...)

Returns the string that results from concatenating the arguments. Returns NULL if any argument is null. may have one or more arguments. If all arguments are non-binary strings, the result is a non-binary string. If the arguments include any binary strings, the result is a binary string. A numeric argument is converted to its equivalent binary string form; If you are want to avoid so you can use explicit type cast, as with this example:select CONCAT (cast (Int_col as CHAR), Char_ Col


Mysql> Select CONCAT (' My ', ' S ', ' QL ');
-> ' MySQL '
Mysql> Select CONCAT (' My ', NULL, ' QL ');
-> NULL
Mysql> Select CONCAT (14.3);
-> ' 14.3 '

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.