說幫助我有2個表:需要使用SQL查詢
Person
- Id
- Name
PersonAttribute
- Id
- PersonId
- Name
- Value
而且,讓我們說,每個人有2種屬性(比如,性別和年齡)。樣本的記錄是這樣的:
Person->Id = 1
Person->Name = 'John Doe'
PersonAttribute->Id = 1
PersonAttribute->PersonId = 1
PersonAttribute->Name = 'Gender'
PersonAttribute->Value = 'Male'
PersonAttribute->Id = 2
PersonAttribute->PersonId = 1
PersonAttribute->Name = 'Age'
PersonAttribute->Value = '30'
問題:我該如何查詢該這樣,我得到這樣一個結果:
「李四」,「男」,「30」
這不能縮放以提取N個通用屬性及其值。 – Timothy 2010-06-02 06:39:35