Help need to with MySQL query to join data spanning multiple tables and use data as column names
Posted
by gurun8
on Stack Overflow
See other posts from Stack Overflow
or by gurun8
Published on 2010-06-10T21:21:55Z
Indexed on
2010/06/11
2:12 UTC
Read the original article
Hit count: 334
I need a little help putting together a SQL query that will give me the following resultsets:
and
The data model looks like this:
The tricky part for me is that the columns to the right of the "Product" in the resultset aren't really columns in the database but rather key/value pairs spanned across the data model.
Table data is as follows:
My apologies in advance for the image heavy question and the image quality. This just seemed like the easiest way to convey the information. It'll probably take someone less time to write the query statement to achieve the results than it did for me to assemble this question.
By the way, the "product_option" table image is truncated but it illustrated the general idea of the data structure.
The MySQL server version is 5.1.45.
© Stack Overflow or respective owner