i could use some help. This is a real-life problem, not homework. I tried all kinds of outer join and union statements, but I am just making a mess.
I have 3 tables:
Table "item":
id | name
---------
1 | 'Item 1'
2 | 'Item 2'
Table "property_type":
id | name
------------------
105 | 'Property A'
106 | 'Property B'
107 | 'Property C'
Table "property" (fk stands for foreign key):
id | fk_item | fk_property_type | value
---------------------------------------------------------------------
1044 | 1 | 106 | 'some value for prop B of item 1'
1045 | 2 | 107 | 'some value for prop C of item 2'
Now I need a statement that produces a property table for a given item id, showing a line for every property type, even if not all properties are set for that item, e.g. if I am interested in item 1, the output should be:
item_name | property_type_name | property_value
------------------------------------------------------------------
'Item 1' | 'Property A' | NULL
'Item 1' | 'Property B' | 'some value for prop B of item 1'
'Item 1' | 'Property C' | NULL
And feel free to suggest a better question title. If I knew how to title this question better I would probably have found the answer by searching myself.