MySQL packet query problem group_concat

Source: Internet
Author: User

These days in the shopping cart. The goods in the shopping cart occupy one line of goods, and when the results are read out from the database, there is no grouping, but the contents are recycled and then judged. If the same thing, save him in a variable. But I don't know the logic. Always out of the bug.

Accidentally reminds of a group query in a SQL statement. Suddenly understand is to do a group query. According to the store group and then the detailed products are combined with group_concat function

Select Store Id,group_concat (Shangpinid) shangpinids from shopping cart GROUP by Store ID

Where Shangpinids is the alias of Group_concat (Shangpinid).

The current situation is only caused by previous SQL statements that cannot be mastered. When writing code, found that the PHP statement is not in place. Time efficiency is low. Therefore, we will strengthen the basic learning of PHP MySQL later.

The following two blog addresses are referenced in this article:

Http://blog.163.com/lgh_2002/blog/static/44017526201111144316650/

http://blog.csdn.net/u012906135/article/details/44350219

MySQL packet query problem group_concat

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.