Title: SQL error working with Database Optimizer
Last modified: April 7, 2019

---

# SQL error working with Database Optimizer

 *  Resolved [German Cabezas](https://wordpress.org/support/users/gercabace/)
 * (@gercabace)
 * [7 years ago](https://wordpress.org/support/topic/sql-error-working-with-database-optimizer/)
 * Hi, I’ve just install last version. When I was clearing “Orphan attachments” (
   Database Optimizer]), this error showed up:
 * ·····························
    [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 ‘WHERE post_type = ‘attachment” at line 1] SELECT ID FROM wp_posts WHERE
   post_parent NOT IN (SELECT ID FROM wp_posts) AND post_parent != 0 WHERE post_type
   = ‘attachment’ ························
 * Maybe WHERE clause should be AND:
    WHERE post_type = ‘attachment’ –> AND post_type
   = ‘attachment’
 * Regards.

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

 *  Plugin Contributor [Fred](https://wordpress.org/support/users/fredawd/)
 * (@fredawd)
 * [7 years ago](https://wordpress.org/support/topic/sql-error-working-with-database-optimizer/#post-11401467)
 * Hi,
 * Thanks for reporting this issue. We are going to fix this in next release.
 *  Thread Starter [German Cabezas](https://wordpress.org/support/users/gercabace/)
 * (@gercabace)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/sql-error-working-with-database-optimizer/#post-11971296)
 * Hi
 * The error are still showing in 2.1
 * Regards.

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

The topic ‘SQL error working with Database Optimizer’ is closed to new replies.

 * ![](https://ps.w.org/swift-performance-lite/assets/icon-256x256.jpg?rev=2388229)
 * [Swift Performance Lite](https://wordpress.org/plugins/swift-performance-lite/)
 * [Support Threads](https://wordpress.org/support/plugin/swift-performance-lite/)
 * [Active Topics](https://wordpress.org/support/plugin/swift-performance-lite/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/swift-performance-lite/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/swift-performance-lite/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [German Cabezas](https://wordpress.org/support/users/gercabace/)
 * Last activity: [6 years, 6 months ago](https://wordpress.org/support/topic/sql-error-working-with-database-optimizer/#post-11971296)
 * Status: resolved