I'm struggling to get following 3 tables into one query:
tPerson
ID          FirstName
1           'Jack'
2           'Liz'
tAttribute
ID          AttributeName
101         'LastName'
102         'Gender'
tData
PersonID    AttributeID     AttributeValue
1           101             'Nicholson'
1           102             'Male'
2           101             'Taylor'
2           102             'Female'
Important: The attributes in tAttribute are dynamic. There could be more, e.g.:
ID          AttributeName
103         'Income'
104         'MostPopularMovie'
Question: How can I write my query (or queries if neccessary), so that I get following output:
PersonID    FirstName   LastName        Gender      [otherFields]
1           'Jack'      'Nicholson'     'Male'      [otherValues]
2           'Liz'       'Taylor'        'Female'    [otherValues]
I often read "What have you tried so far?", but posting all my failed attempts using subqueries and joins wouldn't make much sense. I'm just not that secure with SQL.
Many thanks in advance.
 
    