SQL读取Grid Matrix

时间:2016-08-05 05:48:15

标签: mysql sql

我有一张表(表1)如下:

enter image description here

这是鞋码的网格矩阵。

我想写一个SQL语句来从表1中读取并显示如下

enter image description here

我已经不知道如何为此构造SQL。

1 个答案:

答案 0 :(得分:1)

Create table my_new_table as
   Select grid_code
     ,'size' attribute_type
     , 1 attribute_code
     , size_code_1 attribute_value
  From my_table
 Union
 Select grid_code
     ,'size' attribute_type
     ,  2 attribute_code
     , size_code_2 attribute_value
  From my_table
 ... Etc