I need to export some posts based on custom meta data. I cannot export the ID of the post because I will run into a duplicate key problem when I import the data into a different database.
When I run the SQL query to select which fields, I am excluding the ID:
SELECT 'post_author',
'post_date',
'post_content',
'post_title',
'post_excerpt',
'post_status',
'comment_status',
'ping_status',
'post_password',
'post_name',
'post_modified',
'post_content_filtered',
'post_parent',
'guid',
'post_type',
'post_mime_type',
'comment_count'
FROM wp_posts
INNER JOIN wp_postmeta
ON wp_postmeta.post_ID = wp_posts.ID
WHERE ( wp_postmeta.meta_key = 'InternalOnly'
AND wp_postmeta.meta_value IS NOT NULL );
I get the column title as each entry in the column: http://screencast.com/t/A8ySD6frl6Z
So essentially I need to reference the ID of the post when I run the query but I can’t include the ID in the output. Am I doing something wrong?
You are selecting string literals, not fields. Take out the single quotes and you should be good (assuming that the query is correct)