Sample Block – Queries

WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DESC' at line 1]
SELECT YEAR(p.post_date) FROM pfq_posts AS p RIGHT JOIN pfq_term_relationships AS r ON r.object_id = p.ID WHERE p.post_status = 'publish' AND r.term_taxonomy_id IN (7) GROUP BY YEAR(p.post_date) DESC

WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DESC' at line 25]
SELECT x.name, x.slug, y.term_taxonomy_id FROM pfq_term_relationships AS y LEFT JOIN (SELECT t.name, t.slug, t.term_id FROM pfq_terms AS t INNER JOIN pfq_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = 'post_tag') x ON x.term_id = y.term_taxonomy_id INNER JOIN (SELECT post.ID, y.term_taxonomy_id FROM pfq_posts AS post LEFT JOIN pfq_term_relationships AS y ON y.object_id = post.ID WHERE y.term_taxonomy_id IS NOT NULL AND y.term_taxonomy_id IN (7)) o ON o.ID = y.object_id WHERE x.name IS NOT NULL GROUP BY x.name DESC

WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DESC' at line 1]
SELECT YEAR(p.post_date) FROM pfq_posts AS p RIGHT JOIN pfq_term_relationships AS r ON r.object_id = p.ID WHERE p.post_status = 'publish' GROUP BY YEAR(p.post_date) DESC