About MySQL Query and page display

Source: Internet
Author: User
Dear God, This is the case, now to read the information about the product from the database, and then a product may correspond to a plurality of origin, each origin has the name of the origin, if a product has more than one origin, in the product list corresponding to the search bar can be found in the product name of each of the products to change products, But in the product list of a product can display a record, how can I do?


Reply to discussion (solution)

Motioned
Select Products, Group_concat (origin) as Origin from table group by products

You can get the result.
Product 1 Origin 1, Origin 2, Origin 3

Big God main now SQL too complex ask where to add more appropriate

I don't know how to add it in Left_join.

A table query there are so many joins AH you this SQL statement to optimize the query rather slow

Mainly do the functions involved too much service, this also no way, query speed is OK, now is the function did not meet the demand, the origin of all the query out the list has many records, display a record query origin name also default last tangled then Group_concat in left The join doesn't know how to use the right

It's better to check the display list when you print it.

  • 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.