First time poster. I'm trying to export a bunch of custom posts out to a csv file so I can easily import them into a new database. I've ran the native export to xml, but it's not the correct format I need. I need a column based format (ie. name, height, weight, etc.).
I have a custom post that has several custom fields. I'm having issues combining them all down to one single row, rather than a new row for each meta type. Is there a way to write a sql query that has numerous selects for each meta type and combines them into one row with multiple columns?
Here is what I have so far, which gives me one column and a new row for each meta type for the same Name
SELECT p.post_title AS Name FROM wp_posts AS p INNER JOIN wp_postmeta AS pm ON p.ID = pm.post_id WHERE p.post_type = 'prospects' ORDER BY p.post_date DESC
Now how would I start adding columns (selects) for each meta type and combine them on one row:
AND ( SELECT m1.meta_value AS Height WHERE m1.meta_key = '_height' ) AND ( SELECT m2.meta_value AS Weight WHERE m2.meta_key = '_weight' )