I have 3 tables: device, device_properties, and property. The device_properties tables accomplishes a many-to-many relationship between the device and property tables.
In the sample data below, the device named ABC-2 only has 3 properties, but ABC-1 has 4 properties (as described in the device_properties table):
device device_properties property
id name device_id property_id id name value
1 ABC-1 1 1 1 height 20cm
2 ABC-2 1 3 2 height 30cm
1 4 3 weight 100g
1 5 4 colour black
2 2 5 width 5cm
2 3 6 width 10cm
2 6
How can I retrieve all results from the tables in the following format, given that there are some properties missing for some devices (ABC-2 is missing a colour in this example) ?
deviceId deviceName deviceHeight deviceWeight deviceColour deviceWidth
1 ABC-1 20cm 100g black 5cm
2 ABC-2 30cm 100g ---- 10cm
Thanks in advance for any help!