I need to:
Join wordpress data from multiple tables so all data pertaining to each post resides on a single row for export to CSV.
and
Split data back across the tables during import of the CSV.
I believe this can by done via 2 mySQL queries.
My intention is to export data, manipulate cell values and add new rows for the purpose of bulk editing and creation of new wp posts.
So far I have understood that I can be quite explicit in collating data for export like this:
SELECT DISTINCT
ID, post_author, post_content, post_title
,(SELECT meta_value
FROM wp_postmeta
WHERE wp_postmeta.meta_key = 'wpcf-album-title'
AND wp_postmeta.post_id = wp_posts.ID
) as "wpcf-album-title"
,(SELECT id FROM wp_geo_mashup_locations, wp_geo_mashup_location_relationships WHERE wp_geo_mashup_locations.id = wp_geo_mashup_location_relationships.location_id AND wp_geo_mashup_location_relationships.object_id = wp_posts.ID) as "id"
FROM wp_posts
WHERE post_type = 'post'
ORDER BY
ID, post_author, post_content, post_title
INTO OUTFILE '/tmp/test.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '~'
LINES TERMINATED BY '\n'
The above gives me a selection and export to CSV file.
How do I go back the other way, splitting the data back across the tables?