Skip to content

SQL error due to ambiguous query #20

@RobSkilling

Description

@RobSkilling

We are getting the following error in our logs from Facetious queries:

Dec 3 02:43:46: WordPress database error Column 'post_date' in where clause is ambiguous for query SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) LEFT JOIN wp_posts AS p2 ON (wp_posts.post_parent = p2.ID) WHERE 1=1 AND ( ( YEAR( post_date ) = 2012 AND MONTH( post_date ) = 10 ) ) AND ( wp_term_relationships.term_taxonomy_id IN (30) ) AND wp_posts.post_type IN ('post', 'report') AND ((wp_posts.post_status = 'publish') OR (wp_posts.post_status = 'inherit' AND (p2.post_status = 'publish'))) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10 made by require('wp-blog-header.php'), wp, WP->main, WP->query_posts, WP_Query->query, WP_Query->get_posts

Harry @ DXW suggested the error is generated by line 262 in template.php:

SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month

but looking again now I'm not sure that really matches what we're seeing in the error - it looks like its generated by the main query that Facetious constructs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions