Wordpress SQL Query to get post meta data

Posted by Blake on 11/13/2014
)

Scenario:

You want to query a Wordpress database and get out ther pertinent information related to the current version of a post. The following query works and has been tested with both MySql and a SQLite implementation with Wordpress 4.0. It is look for published posts and pulling back the main information on the post plus who authored it.

SQL:

	select wp.ID, 
		post_date, 
		post_modified,
		post_content,
		post_title,
		post_name,
		display_name
	from wp_posts wp
	left outer join wp_users wu on wu.ID = wp.post_author
	where post_status = 'publish' and post_type = 'post'