Title: Query Problem
Last modified: August 21, 2016

---

# Query Problem

 *  [wayward2012](https://wordpress.org/support/users/wayward2012/)
 * (@wayward2012)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/query-problem-1/)
 * Hi.
 * I have this query:
 *     ```
       $querystr = "
           SELECT $wpdb->posts.*
           FROM $wpdb->posts, $wpdb->top, $wpdb->term_relationships
          	WHERE $wpdb->posts.ID = $wpdb->top.post_id
           AND $wpdb->top.DIA_FINAL >= NOW()
           AND $wpdb->top.ESTADO = 'OK'
       	AND $wpdb->posts.ID = $wpdb->term_relationships.object_id
       	AND $wpdb->term_relationships.term_taxonomy_id = (8,33)
       	ORDER BY RAND()
       	LIMIT 50
       	 ";
       ```
   
 * The query works, but not fine:
 * I want resolve all post for term_taxonomy_id = 8 and inside all post of category
   8, all of category 33. I want not all post of each category.
 * Any idea?
 * thanks

The topic ‘Query Problem’ is closed to new replies.

## Tags

 * [query](https://wordpress.org/support/topic-tag/query/)

 * 0 replies
 * 1 participant
 * Last reply from: [wayward2012](https://wordpress.org/support/users/wayward2012/)
 * Last activity: [12 years, 4 months ago](https://wordpress.org/support/topic/query-problem-1/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
