From http://stackoverflow.com/questions/12855854/export-wordpress-posts-and-meta-information-in-csv-format-using-sql-query