A complicated MYSQL query and arrangement scenario

Source: Internet
Author: User
A product contains data such as the size, color, and quantity of the inventory warehouse. MYSQL stores data based on such fields, but the same volume and different warehouses exist, in the case of different sizes, the data format I need to SELECT now is entry 1 -- 0000001 size color Quantity ---... a product contains

Metric data such as warehouse size and color Quantity
MYSQL stores data based on such fields, but with the same region, different warehouses, and different sizes.

The data format that I need to SELECT now is

Entry 1 -- 0000001 size color Quantity
---- 0000001 warehouse 002 size 1 quantity size 2 quantity size 3 quantity
Entry 2 -- 0000002 size color Quantity
---- 0000002 warehouse 002 size 1 quantity size 2 quantity size 3 quantity
---- 0000002 warehouse 003 size 1 quantity size 2 quantity size 3 quantity
Entry 3 -- 0000003 size color
---- 003 warehouse 003 size 1 quantity size 2 quantity size 3 quantity
....

That is to say, combine the goods of the same shard and separate the different warehouse and different sizes.
How can I write a SELECT statement?
I think it should be to write multiple layers. What is the best way to improve efficiency?

Reply content:

A product contains

Metric data such as warehouse size and color Quantity
MYSQL stores data based on such fields, but with the same region, different warehouses, and different sizes.

The data format that I need to SELECT now is

Entry 1 -- 0000001 size color Quantity
---- 0000001 warehouse 002 size 1 quantity size 2 quantity size 3 quantity
Entry 2 -- 0000002 size color Quantity
---- 0000002 warehouse 002 size 1 quantity size 2 quantity size 3 quantity
---- 0000002 warehouse 003 size 1 quantity size 2 quantity size 3 quantity
Entry 3 -- 0000003 size color
---- 003 warehouse 003 size 1 quantity size 2 quantity size 3 quantity
....

That is to say, combine the goods of the same shard and separate the different warehouse and different sizes.
How can I write a SELECT statement?
I think it should be to write multiple layers. What is the best way to improve efficiency?

What you want to consider is SKU

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.