Skip to content

Incorrect statement #155

@Yogurt4

Description

@Yogurt4

WP Version: 6.8.3
PG4WP Version: 3.4.1

Error:

ERROR:  syntax error at or near "FROM"
LINE 1: ...onth, count( "ID" ) as posts, month ORDER BY year FROM wp_po...

RAW SQL

SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM wp_posts  INNER JOIN wp_term_relationships AS pll_tr ON pll_tr.object_id = wp_posts.ID WHERE post_type = 'post' AND post_status = 'publish' AND pll_tr.term_taxonomy_id = 8 GROUP BY `year`, `month` ORDER BY `year` DESC, `month` DESC 

Expected Rewritten SQL

SELECT EXTRACT(YEAR FROM post_date) AS year, EXTRACT(MONTH FROM post_date) AS month, count( "ID" ) as posts FROM wp_posts  INNER JOIN wp_term_relationships AS pll_tr ON pll_tr.object_id = wp_posts."ID" WHERE post_type = 'post' AND post_status = 'publish' AND pll_tr.term_taxonomy_id = 8 GROUP BY year, month ORDER BY year DESC, month DESC 

Actual Rewritten SQL

SELECT EXTRACT(YEAR FROM post_date) AS year, EXTRACT(MONTH FROM post_date) AS month, count( "ID" ) as posts, month ORDER BY year FROM wp_posts GROUP BY EXTRACT(YEAR FROM post_date) AS year, EXTRACT(MONTH FROM post_date) AS month, month ORDER BY year

It seems as if another variable was used instead of the "INNER JOIN..." part.

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