Newbie Question - How to combine these queries?

I am trying to extract raw data from my WordPress database and have been successful is doing so, but I needed to use a different query every time. Could someone help me out on how to combine these queries into one query?

You would use a left or inner join on it; the former for optional meta keys and the latter for required meta keys. For example:

Code:

SELECT
wp_posts.post_title,
post_type_meta.meta_value AS post_type_value,
mabp_description_meta.meta_value AS mabp_description_value
FROM wp_posts
LEFT JOIN wp_postmeta AS post_type_meta ON
post_type_meta.post_id = wp_posts.ID
AND post_type_meta.meta_key = 'post_type_value'
LEFT JOIN wp_postmeta AS mabp_description_meta ON
mabp_description_meta.post_id = wp_posts.ID
AND mabp_description_meta.meta_key = 'mabp_description'
WHERE wp_posts.ID = '$id'

However, note that:
* The mysql_* PHP library is deprecated and mysqli or PDO should be used instead.
* You don't need to call mysql_num_rows unless you're actually going to use the value.
* mysql_close closes the connection to the MySQL server, which is not what you want to be doing after every query; you shouldn't be calling this in your script.