Need help with SQL Query
Posted
by StackOverflowNewbie
on Stack Overflow
See other posts from Stack Overflow
or by StackOverflowNewbie
Published on 2010-06-02T06:10:47Z
Indexed on
2010/06/02
6:13 UTC
Read the original article
Hit count: 310
Say I have 2 tables:
Person
- Id
- Name
PersonAttribute
- Id
- PersonId
- Name
- Value
Further, let's say that each person had 2 attributes (say, gender and age). A sample record would be like this:
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'
Question: how do I query this such that I get a result like this:
'John Doe', 'Male', '30'
© Stack Overflow or respective owner