MySQL concat concat_ws group_concat function (connection string)

Source: Internet
Author: User

CONCAT (str1,str2,...)   NULL.
Mysql> SelectConcat' One',' A',' -');+------------------------+|Concat' One',' A',' -')|+------------------------+| 112233 |+------------------------+
Mysql> SelectConcat_ws (',',' One',' A',' -');+-------------------------------+|Concat_ws (',',' One',' A',' -')|+-------------------------------+|  One, A, - |+-------------------------------+
Group_concat ([DISTINCT]The field to connect to[ORDER by Asc/desc sort field] [Separator ' delimiter ']) basic query MySQL> Select *  fromAA;+------+------+|Id|Name|+------+------+|1 | Ten||1 |  -||1 |  -||2 |  -||3 |  $   ||3 |  -   |+------+------+6Rowsinch Set(0.00sec) Group by ID, print the value of the Name field on one line, comma separated (default) MySQL> SelectId,group_concat (name) fromAaGroup  byID;+------+--------------------+|Id|Group_concat (name)|+------+--------------------+|1 | Ten, -, -||2 |  - ||3 |  $, -|+------+--------------------+
GROUP by ID, print the value of the Name field in one line, comma-delimited, and reverse-order in the name column MySQL> SelectId,group_concat (nameOrder  byNamedesc) fromAaGroup  byID;+------+---------------------------------------+|Id|Group_concat (nameOrder  byNamedesc)|+------+---------------------------------------+|1 |  -, -,Ten   ||2 |  -||3 |  -, $|+------+---------------------------------------+
GROUP by ID, print the value of the Remove redundant name field in one line, comma separated MySQL> SelectId,group_concat (distinctName fromAaGroup  byID;+------+-----------------------------+|Id|Group_concat (distinctName|+------+-----------------------------+|1 | Ten, -||2 |  -   ||3 |  $, - |+------+-----------------------------+

MySQL concat concat_ws group_concat function (connection string)

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.