具有典型属性表的SQL查询

时间:2014-08-13 19:31:46

标签: sql mysqli

寻求有关构建SQL查询的帮助:

我有两张桌子:

表1 - 对象:

object_id    name       owner
1           Object1    Owner1
2           Object2    Owner2
3           Object3    Owner3

表2 - 对象属性(每个对象只有3个属性)

object_id         property_name       Property_value
    1                   color              blue
    1                   shape              circle
    1                   inhouse            true
    2                   color              red
    2                   shape              rectangle
    2                   inhouse            false
    3                   color              green
    3                   shape              rectangle
    3                   inhouse            true

我想构建一个这样的视图:

name       owner      color       shape       inhouse
Object1    Owner1     blue       circle       true
Object2    Owner2     red        rectangle    false
Object3    Owner3     green      rectangle    true

0 个答案:

没有答案