【发布时间】:2016-01-07 05:26:22
【问题描述】:
我有一个 Person 表,其中包含多个 Attributes,我想加入它们,所以我得到这样的结果:
First_Name | Last_Name | Attribute
======================================================
John | Smith | Cool, Tall, Brown Hair
Steve | Bob | Impatient, Short, Blonde Hair
Hector | Hector | Groovy, Funny, Black Hair
这些表格是:
Person {id, first_name, last_name}
Attribute {id, description}
Ref_Attribute {id, ref_person_id, ref_attribute_id}
我知道我可以使用 GROUP_CONCAT 并最终使用 GROUP BY person.id,但我不想使用 GROUP BY,因为我需要加入另一个表,我需要将它们分隔为不同的行。要加入的表是House。这意味着,如果一个人有多个房子,那么它将给出:
First_Name | Last_Name | Attribute | House
=======================================================================
John | Smith | Cool, Tall, Brown Hair | Bourke St. Ave
Steve | Bob | Impatient, Short, Blonde Hair | Flinders St.
Hector | Hector | Groovy, Funny, Black Hair | Crown Golf
有没有什么方法可以在没有 GROUP BY 的情况下加入并获得结果?
【问题讨论】: