I have a table wmeta
of meta data for items: (some items have missing data) Simplified example:
id | item_id | meta_key | meta_value
1 |100 |first_name |Joe
2 |100 |last_name |Bloggs
3 |100 |age |21
4 |101 |first_name |Fred
5 |101 |last_name |Smith
6 |102 |first_name |Jane
7 |102 |last_name |Doe
8 |102 |age |22
If I have another table wfields
with all the keys
id |meta_name
1 |first_name
2 |last_name
3 |age
using the query below I am not getting the null I expected for the missing age record.
SELECT wf.meta_name, wm.item-id, wm.meta_value
FROM wfields as wf
LEFT JOIN wmeta as wm
ON wf.meta_name = wm.meta_key
The output I want is for a table display/export to csv
100 | Joe Bloggs 22
101 | Fred Smith ''
102 | Jane Doe 21