Title: sing query_posts in sql condition 0=1
Last modified: August 30, 2016

---

# sing query_posts in sql condition 0=1

 *  [mstdmstd](https://wordpress.org/support/users/mstdmstd/)
 * (@mstdmstd)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/sing-query_posts-in-sql-condition-01/)
 * Hi all,
    In WP 4.2 project I want to make request on posts with condition like
 *     ```
       query_posts( 'post_type=artists_songs&cat='.$artistsCategory->term_id );
       ```
   
 * But it did not returned result set I expected.
    I made some sql debugging and
   found then sql looks like :
 *     ```
       SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID
         FROM wp_posts
        WHERE 1=1  AND (
         0 = 1
       ) AND wp_posts.post_type = 'artists_songs' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'future' OR wp_posts.post_status = 'draft' OR wp_posts.post_status = 'pending' OR wp_posts.post_status = 'private')
         GROUP BY wp_posts.ID
         ORDER BY wp_posts.post_date DESC LIMIT 0, 10
       ```
   
 * If manually to remove 1 line
    0 = 1 it works ok. It was strange for me why this
   condition was generated and how to remove it? Any ideas?
 * Actually I used similar conditition I started at the beginning and it worked 
   ok…

Viewing 1 replies (of 1 total)

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/sing-query_posts-in-sql-condition-01/#post-6216610)
 * I suspect that $artistsCategory->term_id does not contain an integer. Use print_r
   to see its actual contents:
 *     ```
       print_r('<pre>CAT:');print_r($artistsCategory->term_id);print_r('</pre>');
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘sing query_posts in sql condition 0=1’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * Last activity: [10 years, 11 months ago](https://wordpress.org/support/topic/sing-query_posts-in-sql-condition-01/#post-6216610)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
