{"id":18644245,"date":"2025-09-16T18:25:14","date_gmt":"2025-09-16T18:25:14","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/sql-syntax-error-25\/"},"modified":"2025-09-16T18:25:14","modified_gmt":"2025-09-16T18:25:14","slug":"sql-syntax-error-25","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/sql-syntax-error-25\/","title":{"rendered":"SQL Syntax Error"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Seeing this SQL syntax error in the error_log occasionally. It looks like both an INNER JOIN and a LEFT JOIN use <code>wp_postmeta<\/code> without an alias.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>&#091;12-Sep-2025 14:33:54 UTC] WordPress database error Not unique table\/alias: 'wp_postmeta' for query SELECT SQL_CALC_FOUND_ROWS DISTINCT wp_posts.ID<br \/>FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) LEFT JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id LEFT JOIN wp_term_relationships AS trel ON (wp_posts.ID = trel.object_id) LEFT JOIN wp_term_taxonomy AS ttax ON (( ttax.taxonomy = 'ml-slider' ) AND trel.term_taxonomy_id = ttax.term_taxonomy_id) LEFT JOIN wp_terms AS tter ON (ttax.term_id = tter.term_id)<br \/>WHERE 1=1 AND wp_posts.post_type = 'attachment' AND (wp_posts.post_status = 'inherit' OR wp_posts.post_status = 'private') AND ( (wp_posts.ID LIKE '%transfer station%') OR (wp_posts.post_title LIKE '%transfer station%') OR (wp_posts.guid LIKE '%transfer station%') OR (wp_posts.post_content LIKE '%transfer station%') OR (wp_posts.post_excerpt LIKE '%transfer station%') OR (wp_postmeta.meta_key = '_wp_attachment_image_alt' AND wp_postmeta.meta_value LIKE '%transfer station%') OR (wp_postmeta.meta_key = '_wp_attached_file' AND wp_postmeta.meta_value LIKE '%transfer station%') OR (tter.slug LIKE '%transfer station%') OR (ttax.description LIKE '%transfer station%') OR (tter.name LIKE '%transfer station%') )<br \/>GROUP BY wp_posts.ID<br \/>ORDER BY wp_posts.post_date DESC<br \/>LIMIT 0, 100 made by require_once('wp-admin\/admin-header.php'), do_action('admin_enqueue_scripts'), WP_Hook-&gt;do_action, WP_Hook-&gt;apply_filters, PublishPress\\Future\\Modules\\Workflows\\Controllers\\FutureLegacyAction-&gt;enqueueScriptsLegacyAction, PublishPress\\Future\\Modules\\Workflows\\Models\\WorkflowsModel-&gt;getPublishedWorkflowsWithLegacyTriggerAsOptions, PublishPress\\Future\\Modules\\Workflows\\Models\\WorkflowsModel-&gt;getPublishedWorkflowsWithMetadataAsOptions, WP_Query-&gt;__construct, WP_Query-&gt;query, WP_Query-&gt;get_posts<br \/><br \/><br \/>&#091;12-Sep-2025 14:34:05 UTC] WordPress database error Not unique table\/alias: 'wp_postmeta' for query SELECT SQL_CALC_FOUND_ROWS DISTINCT wp_posts.ID<br \/>FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) LEFT JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id LEFT JOIN wp_term_relationships AS trel ON (wp_posts.ID = trel.object_id) LEFT JOIN wp_term_taxonomy AS ttax ON (( ttax.taxonomy = 'ml-slider' ) AND trel.term_taxonomy_id = ttax.term_taxonomy_id) LEFT JOIN wp_terms AS tter ON (ttax.term_id = tter.term_id)<br \/>WHERE 1=1 AND wp_posts.post_type = 'attachment' AND (wp_posts.post_status = 'inherit' OR wp_posts.post_status = 'private') AND ( (wp_posts.ID LIKE '%transfer station%') OR (wp_posts.post_title LIKE '%transfer station%') OR (wp_posts.guid LIKE '%transfer station%') OR (wp_posts.post_content LIKE '%transfer station%') OR (wp_posts.post_excerpt LIKE '%transfer station%') OR (wp_postmeta.meta_key = '_wp_attachment_image_alt' AND wp_postmeta.meta_value LIKE '%transfer station%') OR (wp_postmeta.meta_key = '_wp_attached_file' AND wp_postmeta.meta_value LIKE '%transfer station%') OR (tter.slug LIKE '%transfer station%') OR (ttax.description LIKE '%transfer station%') OR (tter.name LIKE '%transfer station%') )<br \/>GROUP BY wp_posts.ID<br \/>ORDER BY wp_posts.post_date DESC<br \/>LIMIT 0, 100 made by require_once('wp-admin\/admin-header.php'), do_action('admin_enqueue_scripts'), WP_Hook-&gt;do_action, WP_Hook-&gt;apply_filters, PublishPress\\Future\\Modules\\Workflows\\Controllers\\FutureLegacyAction-&gt;enqueueScriptsLegacyAction, PublishPress\\Future\\Modules\\Workflows\\Models\\WorkflowsModel-&gt;getPublishedWorkflowsWithLegacyTriggerAsOptions, PublishPress\\Future\\Modules\\Workflows\\Models\\WorkflowsModel-&gt;getPublishedWorkflowsWithMetadataAsOptions, WP_Query-&gt;__construct, WP_Query-&gt;query, WP_Query-&gt;get_posts<br \/><\/code><br \/><code>&#091;12-Sep-2025 14:34:11 UTC] WordPress database error Not unique table\/alias: 'wp_postmeta' for query SELECT SQL_CALC_FOUND_ROWS DISTINCT wp_posts.ID<br \/>FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) LEFT JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id LEFT JOIN wp_term_relationships AS trel ON (wp_posts.ID = trel.object_id) LEFT JOIN wp_term_taxonomy AS ttax ON (( ttax.taxonomy = 'ml-slider' ) AND trel.term_taxonomy_id = ttax.term_taxonomy_id) LEFT JOIN wp_terms AS tter ON (ttax.term_id = tter.term_id)<br \/>WHERE 1=1 AND wp_posts.post_type = 'attachment' AND (wp_posts.post_status = 'inherit' OR wp_posts.post_status = 'private') AND ( (wp_posts.ID LIKE '%transfer station%') OR (wp_posts.post_title LIKE '%transfer station%') OR (wp_posts.guid LIKE '%transfer station%') OR (wp_posts.post_content LIKE '%transfer station%') OR (wp_posts.post_excerpt LIKE '%transfer station%') OR (wp_postmeta.meta_key = '_wp_attachment_image_alt' AND wp_postmeta.meta_value LIKE '%transfer station%') OR (wp_postmeta.meta_key = '_wp_attached_file' AND wp_postmeta.meta_value LIKE '%transfer station%') OR (tter.slug LIKE '%transfer station%') OR (ttax.description LIKE '%transfer station%') OR (tter.name LIKE '%transfer station%') )<br \/>GROUP BY wp_posts.ID<br \/>ORDER BY wp_posts.post_date DESC<br \/>LIMIT 0, 100 made by require_once('wp-admin\/admin-header.php'), do_action('admin_enqueue_scripts'), WP_Hook-&gt;do_action, WP_Hook-&gt;apply_filters, PublishPress\\Future\\Modules\\Workflows\\Controllers\\FutureLegacyAction-&gt;enqueueScriptsLegacyAction, PublishPress\\Future\\Modules\\Workflows\\Models\\WorkflowsModel-&gt;getPublishedWorkflowsWithLegacyTriggerAsOptions, PublishPress\\Future\\Modules\\Workflows\\Models\\WorkflowsModel-&gt;getPublishedWorkflowsWithMetadataAsOptions, WP_Query-&gt;__construct, WP_Query-&gt;query, WP_Query-&gt;get_posts<br \/><\/code><br \/><code>&#091;12-Sep-2025 14:34:26 UTC] WordPress database error Not unique table\/alias: 'wp_postmeta' for query SELECT SQL_CALC_FOUND_ROWS DISTINCT wp_posts.ID<br \/>FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) LEFT JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id LEFT JOIN wp_term_relationships AS trel ON (wp_posts.ID = trel.object_id) LEFT JOIN wp_term_taxonomy AS ttax ON (( ttax.taxonomy = 'ml-slider' ) AND trel.term_taxonomy_id = ttax.term_taxonomy_id) LEFT JOIN wp_terms AS tter ON (ttax.term_id = tter.term_id)<br \/>WHERE 1=1 AND wp_posts.post_type = 'attachment' AND (wp_posts.post_status = 'inherit' OR wp_posts.post_status = 'private') AND ( (wp_posts.ID LIKE '%transfer station%') OR (wp_posts.post_title LIKE '%transfer station%') OR (wp_posts.guid LIKE '%transfer station%') OR (wp_posts.post_content LIKE '%transfer station%') OR (wp_posts.post_excerpt LIKE '%transfer station%') OR (wp_postmeta.meta_key = '_wp_attachment_image_alt' AND wp_postmeta.meta_value LIKE '%transfer station%') OR (wp_postmeta.meta_key = '_wp_attached_file' AND wp_postmeta.meta_value LIKE '%transfer station%') OR (tter.slug LIKE '%transfer station%') OR (ttax.description LIKE '%transfer station%') OR (tter.name LIKE '%transfer station%') )<br \/>GROUP BY wp_posts.ID<br \/>ORDER BY wp_posts.post_date DESC<br \/>LIMIT 0, 100 made by require_once('wp-admin\/admin-header.php'), do_action('admin_enqueue_scripts'), WP_Hook-&gt;do_action, WP_Hook-&gt;apply_filters, PublishPress\\Future\\Modules\\Workflows\\Controllers\\FutureLegacyAction-&gt;enqueueScriptsLegacyAction, PublishPress\\Future\\Modules\\Workflows\\Models\\WorkflowsModel-&gt;getPublishedWorkflowsWithLegacyTriggerAsOptions, PublishPress\\Future\\Modules\\Workflows\\Models\\WorkflowsModel-&gt;getPublishedWorkflowsWithMetadataAsOptions, WP_Query-&gt;__construct, WP_Query-&gt;query, WP_Query-&gt;get_posts<\/code><\/code><\/pre>\n","protected":false},"template":"","class_list":["post-18644245","topic","type-topic","status-publish","hentry","topic-tag-sql"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/18644245","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/18644245\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=18644245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}