Quantcast
Channel: Question and Answer » wpdb
Viewing all articles
Browse latest Browse all 44

WPDB SQL Ignore `post_status` Parameter

$
0
0

I use this SQL statement:

SELECT * FROM wp_posts
    LEFT JOIN wp_term_relationships ON ( wp_posts.ID = wp_term_relationships.object_id )
    LEFT JOIN wp_term_taxonomy ON ( wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id )
    WHERE wp_posts.post_type = 'post'
        AND wp_posts.post_status = 'publish'
        AND wp_posts.post_status != 'draft'
        AND wp_term_taxonomy.term_id = 17
        OR wp_term_taxonomy.term_id = 18
        OR wp_term_taxonomy.term_id = 19
    ORDER BY post_date_gmt DESC 
    LIMIT 6 
    OFFSET 6

but result of this show posts that have post_status = draft.

Why this happening?


Viewing all articles
Browse latest Browse all 44

Trending Articles