Title: WP Database error (SQL Syntax)
Last modified: September 20, 2017

---

# WP Database error (SQL Syntax)

 *  Resolved [byte37](https://wordpress.org/support/users/byte37/)
 * (@byte37)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/wp-database-error-sql-syntax/)
 * Dear support,
    this morning i went on my woocommerce products and noticed an 
   error showing up, then i went to check it the error log and it says:
 * [20-Sep-2017 09:18:25 UTC] WordPress errore sul database 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 ‘%1$s )’ at line 3 per la query
    SELECT internal_link_count,
   incoming_link_count, object_id FROM wpCBI_yoast_seo_meta WHERE object_id IN (%
   1$s ) fatta da WP_List_Table->display, WP_List_Table->display_tablenav, WP_Posts_List_Table-
   >extra_tablenav, do_action(‘manage_posts_extra_tablenav’), WP_Hook->do_action,
   WP_Hook->apply_filters, WPSEO_Link_Columns->count_objects, WPSEO_Link_Columns-
   >set_count_objects, WPSEO_Link_Column_Count->set, WPSEO_Link_Column_Count->get_results[
   20-Sep-2017 09:18:39 UTC] WordPress errore sul database 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 ‘%1$s )’ at line 3 per la query SELECT internal_link_count,
   incoming_link_count, object_id FROM wpCBI_yoast_seo_meta WHERE object_id IN (%
   1$s ) fatta da WP_List_Table->display, WP_List_Table->display_tablenav, WP_Posts_List_Table-
   >extra_tablenav, do_action(‘manage_posts_extra_tablenav’), WP_Hook->do_action,
   WP_Hook->apply_filters, WPSEO_Link_Columns->count_objects, WPSEO_Link_Columns-
   >set_count_objects, WPSEO_Link_Column_Count->set, WPSEO_Link_Column_Count->get_results
 * Why did it come out like this?
    Thanks

Viewing 8 replies - 1 through 8 (of 8 total)

 *  [wordpressbeta](https://wordpress.org/support/users/wordpressbeta/)
 * (@wordpressbeta)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/wp-database-error-sql-syntax/#post-9512867)
 * Hi,
 * Try This in File wordpress-seo\admin\links\class-link-column-count.php in function
   name get_results().
 * Please change the following query.
 * Before Changing query:
 * $results = $wpdb->get_results(
    $wpdb->prepare( ‘ SELECT internal_link_count,
   incoming_link_count, object_id FROM ‘ . $storage->get_table_name() . ‘ WHERE 
   object_id IN ( %1$s )’, implode( ‘,’, $post_ids ) ), ARRAY_A );
 * After Changing query:
 * $imploded_post_ids = implode( ‘,’, $post_ids );
    $results = $wpdb->get_results(‘
   SELECT internal_link_count, incoming_link_count, object_id FROM ‘ . $storage-
   >get_table_name() . ‘ WHERE object_id IN ( ‘.$imploded_post_ids.’)’,ARRAY_A );
   and check. This solved my problem. Thanks
 *  [witters](https://wordpress.org/support/users/witters/)
 * (@witters)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/wp-database-error-sql-syntax/#post-9512991)
 * I’m also seeing this error, which started after the update to WP 4.8.2:
 *     ```
       [20-Sep-2017 08:45:07 UTC] 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 '%2$s
       			 WHERE target_post_id IN( %3$s )
       		  GROUP BY target_post_id' at line 2 for query 
       			SELECT COUNT( id ) AS incoming, target_post_id AS post_id
       			  FROM %2$s
       			 WHERE target_post_id IN( %3$s )
       		  GROUP BY target_post_id made by edit_post, wp_update_post, wp_insert_post, do_action('save_post'), WP_Hook->do_action, WP_Hook->apply_filters, WPSEO_Link_Watcher->save_post, WPSEO_Link_Content_Processor->process, WPSEO_Link_Content_Processor->update_incoming_links, WPSEO_Meta_Storage->update_incoming_link_count
       ```
   
 * If [@wordpressbeta](https://wordpress.org/support/users/wordpressbeta/)’s comment
   is correct (I’ve not tried it) this would fit with the change to `$wpdb->prepare()`
   noted in the [4.8.2 release notes](https://wordpress.org/news/2017/09/wordpress-4-8-2-security-and-maintenance-release/).
 *  [wordpressbeta](https://wordpress.org/support/users/wordpressbeta/)
 * (@wordpressbeta)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/wp-database-error-sql-syntax/#post-9513053)
 * Hi,
 * You can also try this in File wordpress-seo\admin\links\class-link-column-count.
   php in function name get_results().
 * $no_strings = count($post_ids);
    $ids_placeholders = array_fill(0, $no_strings,“%
   d”); $format = implode(‘, ‘, $ids_placeholders); $results = $wpdb->get_results(
   $wpdb->prepare ( ‘SELECT internal_link_count, incoming_link_count, object_id 
   FROM ‘ . $storage->get_table_name() . ‘ WHERE object_id IN (‘.$format.’)’, $post_ids),
   ARRAY_A ); This too solved your problem. Thanks
 *  [witters](https://wordpress.org/support/users/witters/)
 * (@witters)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/wp-database-error-sql-syntax/#post-9513211)
 * Sure. I’ve no doubt this would patch the issue, but it’s not a long-term fix.(
   It’s bad practice to modify plugin code).
 * We need Yoast to correct their plugin. This thread (and the other similar ones)
   show it’s a broader issue with the 4.8.2 WP core that Yoast need to address.
 *  [marcanor](https://wordpress.org/support/users/marcanor/)
 * (@marcanor)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/wp-database-error-sql-syntax/#post-9513575)
 * Hello,
    This issue has been corrected in the latest release of the Yoast plugin.
   Please update to Yoast SEO 5.4.1.
 * Thanks!
 *  [turquaze](https://wordpress.org/support/users/turquaze/)
 * (@turquaze)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/wp-database-error-sql-syntax/#post-9513682)
 * thank you so much 🙂
 *  [kariravantti](https://wordpress.org/support/users/kariravantti/)
 * (@kariravantti)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/wp-database-error-sql-syntax/#post-9516164)
 * Hi
 * We had similar errors:
 * [Thu Sep 21 08:38:59.717727 2017] [:error] [pid 30293] [client 109.204.149.225:
   54228] WordPress-tietokannan virhe 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 ‘%1$s )’ at line 3 kyselylle \n\t\t\t\tSELECT internal_link_count,
   incoming_link_count, object_id\n\t\t\t\tFROM ss_yoast_seo_meta\n\t\t\t WHERE 
   object_id IN ( %1$s ) Tekij\xc3\xa4: WP_List_Table->display, WP_List_Table->display_tablenav,
   WP_Posts_List_Table->extra_tablenav, do_action(‘manage_posts_extra_tablenav’),
   WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, WPSEO_Link_Columns-
   >count_objects, WPSEO_Link_Columns->set_count_objects, WPSEO_Link_Column_Count-
   >set, WPSEO_Link_Column_Count->get_results, referer: [https://salpaus-testi.aurorads.pro/wp-admin/](https://salpaus-testi.aurorads.pro/wp-admin/)
   [
   Thu Sep 21 08:39:05.692699 2017] [:error] [pid 30285] [client 109.204.149.225:
   54226] WordPress-tietokannan virhe 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 ‘%1$s )’ at line 3 kyselylle \n\t\t\t\tSELECT internal_link_count,
   incoming_link_count, object_id\n\t\t\t\tFROM ss_yoast_seo_meta\n\t\t\t WHERE 
   object_id IN ( %1$s ) Tekij\xc3\xa4: WP_List_Table->display, WP_List_Table->display_tablenav,
   WP_Posts_List_Table->extra_tablenav, do_action(‘manage_posts_extra_tablenav’),
   WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, WPSEO_Link_Columns-
   >count_objects, WPSEO_Link_Columns->set_count_objects, WPSEO_Link_Column_Count-
   >set, WPSEO_Link_Column_Count->get_results, referer: [https://salpaus-testi.aurorads.pro/wp-admin/edit.php?post_type=page](https://salpaus-testi.aurorads.pro/wp-admin/edit.php?post_type=page)[
   Thu Sep 21 08:39:07.543126 2017] [:error] [pid 30293] [client 109.204.149.225:
   54228] WordPress-tietokannan virhe 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 ‘%1$s )’ at line 3 kyselylle \n\t\t\t\tSELECT internal_link_count,
   incoming_link_count, object_id\n\t\t\t\tFROM ss_yoast_seo_meta\n\t\t\t WHERE 
   object_id IN ( %1$s ) Tekij\xc3\xa4: WP_List_Table->display, WP_List_Table->display_tablenav,
   WP_Posts_List_Table->extra_tablenav, do_action(‘manage_posts_extra_tablenav’),
   WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, WPSEO_Link_Columns-
   >count_objects, WPSEO_Link_Columns->set_count_objects, WPSEO_Link_Column_Count-
   >set, WPSEO_Link_Column_Count->get_results, referer: [https://salpaus-testi.aurorads.pro/wp-admin/edit.php?post_type=page](https://salpaus-testi.aurorads.pro/wp-admin/edit.php?post_type=page)
 * With previous version of YOAST, disabling it helped. After installed the latest
   version sites are still broken even YOAST is disabled!
 *  [ZW13](https://wordpress.org/support/users/zw13/)
 * (@zw13)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/wp-database-error-sql-syntax/#post-9530982)
 * Our “Yoast SEO” 5.4 was causing this WordPress database error too, visible on
   the Admin Desktop.
 * 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‘%
   1$s)’ at line 3]
 * SELECT internal_link_count, incoming_link_count, object_id FROM …_yoast_seo_meta
   WHERE object_id IN (%1$s)
 * We have WordPress 4.8.2.
    Yoast SEO update onto 5.5. helped, the error seems 
   to be away.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘WP Database error (SQL Syntax)’ is closed to new replies.

 * ![](https://ps.w.org/wordpress-seo/assets/icon-256x256.gif?rev=3419908)
 * [Yoast SEO - Advanced SEO with real-time guidance and built-in AI](https://wordpress.org/plugins/wordpress-seo/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordpress-seo/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordpress-seo/)
 * [Active Topics](https://wordpress.org/support/plugin/wordpress-seo/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordpress-seo/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordpress-seo/reviews/)

## Tags

 * [database](https://wordpress.org/support/topic-tag/database/)
 * [sql](https://wordpress.org/support/topic-tag/sql/)
 * [WordPress database error](https://wordpress.org/support/topic-tag/wordpress-database-error/)

 * 8 replies
 * 7 participants
 * Last reply from: [ZW13](https://wordpress.org/support/users/zw13/)
 * Last activity: [8 years, 8 months ago](https://wordpress.org/support/topic/wp-database-error-sql-syntax/#post-9530982)
 * Status: resolved