Apologies, this is a duplicate of entry of this post but I found I'm not getting the right answer there and not sure how to ask to move it over to SO?
I need to export all WordPress Posts and related Meta information using an SQL query in CSV format. I've managed to export just the Posts but realised that the Meta information is in another table.
Could someone please tell me how I would go about doing this please?
Thanks!
EDIT: I have already tried a number of plugins, none of which have worked for this specific scenario. I really do need to work on the query itself. Thanks
EDIT: The final outcome of the CSV file should look something like this. On one row, these are the columns that I will end up with. (I will delete the additional columns in CSV, I'm just giving a shortened version here)
post_content | post_title | **meta_key** | *meta_value* | **meta_key** | *meta_value* | **meta_key** | *meta_value* | **meta_key** | *meta_value* | **meta_key** | *meta_value*
So one post per row with the meta information in the same row.
EDIT: With the S-ha-dum, I've managed to get some way, but I have about 12 meta_value > meta_key values to pull out of the DB so I need help to write the rest of the query please
SELECT *,(SELECT meta_value FROM wp_postmeta WHERE wp_postmeta.meta_key = 'Publisher' AND wp_postmeta.post_id = wp_posts.ID) as Publisher FROM wp_posts