Hi,I am working in wordpress database. I have to pick up the records from wp_posts table with in specifed category. Categories are saved under wp_term_relationships table having field name: term_taxonomy_id so i am using left join as:

explain SELECT wp_posts.*, wp_term_relationships.term_taxonomy_id FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID=wp_term_relationships.object_id) WHERE wp_posts.post_type='post' and wp_posts.post_status='publish' and (wp_term_relationships.term_taxonomy_id=8 or wp_term_relationships.term_taxonomy_id=1) ORDER BY wp_posts.post_date desc LIMIT 0, 2