Title: SQL Query :: SELECT post from category ?
Last modified: August 19, 2016

---

# SQL Query :: SELECT post from category ?

 *  Resolved [markval](https://wordpress.org/support/users/markval/)
 * (@markval)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/sql-query-select-post-from-category/)
 * Hi all,
 * I want to make a Query in phpMyAdmin to return post from a category.
 * I think I have to make a combination of :
    wp_posts wp_terms wp_term_relationships
   wp_term_taxonomy
 * I am a ActionScript developper who’s building a Framework to display WP post 
   in Flash using AMFphp and 90% of it is done. I don’t play often in MySQL Query.
   Any help would be greatly appreciated and my Framework will be OpenSource once
   finalized.
 * Regards,
    Mark

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [mrmist](https://wordpress.org/support/users/mrmist/)
 * (@mrmist)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/sql-query-select-post-from-category/#post-968728)
 * This query lists post ids and their asscoiated categorys
 * `select wpr.object_id, wp_terms.name from wp_terms inner join wp_term_taxonomy
   on wp_terms.term_id = wp_term_taxonomy.term_id inner join wp_term_relationships
   wpr on wpr.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id where`taxonomy`
   = "category" order by object_id;`
 * So you could limit that appropriately with the where clause as needed.
 *  [mrmist](https://wordpress.org/support/users/mrmist/)
 * (@mrmist)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/sql-query-select-post-from-category/#post-968740)
 * Or for a more expansive version with better clarity –
 * select p.post_title, wpr.object_id, wp_terms.name
    from wp_terms inner join wp_term_taxonomy
   on wp_terms.term_id = wp_term_taxonomy.term_id inner join wp_term_relationships
   wpr on wpr.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id inner join wp_posts
   p on p.ID = wpr.object_id where taxonomy= “category” and p.post_type = ‘post’
   order by object_id;
 *  Thread Starter [markval](https://wordpress.org/support/users/markval/)
 * (@markval)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/sql-query-select-post-from-category/#post-968798)
 * Wow this will help me out a lot!
 * Thank you very much!
 * I do understand how it works now and it is pretty simple in some way!
 *  [shelzmike](https://wordpress.org/support/users/shelzmike/)
 * (@shelzmike)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/sql-query-select-post-from-category/#post-968994)
 * Not to dredge up an old post, but is there a way to actually limit which category
   is pulled. Meaning, instead of pulling all posts listed by category, how could
   I pull posts only in one category?

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘SQL Query :: SELECT post from category ?’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 3 participants
 * Last reply from: [shelzmike](https://wordpress.org/support/users/shelzmike/)
 * Last activity: [16 years, 11 months ago](https://wordpress.org/support/topic/sql-query-select-post-from-category/#post-968994)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
