The group_concat () function of MYSQL combines multiple rows of the same field into one data.

Source: Internet
Author: User


The group_concat () function of MYSQL combines multiple rows and the same field data into a data table. The SQL code of the access group table is select a. t_applypersondocno, a. t_id from sx_fms_taskinfo a www.2cto.com.
SQL code select * from sx_fms_taskinfoid_countryid result set
Data Table Country info table SQL code select c_id, c_name from sx_fms_countryinfo www.2cto.com result set is associated and then the visited countries are combined (before the combination)
SQL code select taskinfo. t_applypersondocno, countryinfo. c_name from sx_fms_taskinfo taskinfo left join sx_fms_taskinfoid_countryid tcinfo on taskinfo. t_id = tcinfo. t_id left join sx_fms_countryinfo countryinfo on tcinfo. c_id = countryinfo. the c_id is associated before the combination, and then the visiting countries are combined (after the combination) using group_concat (c_name)
SQL code www.2cto.com select taskinfo. t_applypersondocno, group_concat (c_name) from sx_fms_taskinfo taskinfo left join sx_fms_taskinfoid_countryid tcinfo on taskinfo. t_id = tcinfo. t_id left join sx_fms_countryinfo countryinfo on tcinfo. c_id = countryinfo. c_id group by taskinfo. after the t_applypersondocno combination

 

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.