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