I have two tables, call them Parents
and Properties
Each parent has various columns and a id
field. Each property has a key
, a value
column and a parent_id
column that is a foreign key to the parent table. The key and the value can be any string. Each parent has zero or more properties.
How can I select on the same row the parent (and its columns) and all the linked properties? Thanks
EDIT Its is ok for me to select all the joined values as a csv-like string, for example "key1|val1|key2|val2|key2|val2|".
Example of wanted output
|parent_id|parent_name|prop_key1|prop_val1|prop_key2|prop_val2|prop_key3|prop_val3|
|---------------------------------------------------------------------------------|
|1 |foo |key1 |val1 |key2 |val2 | | |
|2 |foo |key1 |val1 |key2 |val2 |key3 |val3 |
|3 |foo | | | | | | |
|4 |foo |key1 |val1 |key2 |val2 |key3 |val3 |
|4 |foo |key1 |val1 | | | | |
SAMPLE DATA: