Title: Database error
Last modified: January 25, 2026

---

# Database error

 *  Resolved [JapeNZ](https://wordpress.org/support/users/japenz/)
 * (@japenz)
 * [4 months, 1 week ago](https://wordpress.org/support/topic/database-error-428/)
 * Hi there,
 * I’m seeing the following issue in my debug log and the CPU usage for my site 
   is very high.
   [25-Jan-2026 03:43:27 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 ‘THEN 2 ELSE 6 END), wp_posts.post_date
   DESC LIMIT 0, 50’ at line 11 for query SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
   FROM wp_posts WHERE 1=1 AND ( wp_posts.ID NOT IN ( SELECT object_id FROM wp_term_relationships
   WHERE term_taxonomy_id IN (2622,2625) ) ) AND (((wp_posts.post_title NOT LIKE‘%
   flex%’) AND (wp_posts.post_excerpt NOT LIKE ‘%flex%’) AND (wp_posts.post_content
   NOT LIKE ‘%flex%’))) AND (wp_posts.post_password = ”) AND ((wp_posts.post_type
   = ‘product’ AND (wp_posts.post_status = ‘publish’))) GROUP BY wp_posts.ID ORDER
   BY (CASE WHEN THEN 2 ELSE 6 END), wp_posts.post_date DESC LIMIT 0, 50 made by
   require(‘wp-blog-header.php’), wp, WP->main, WP->query_posts, WP_Query->query,
   WP_Query->get_posts[25-Jan-2026 03:43:28 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 ‘THEN 2 ELSE 6 END), wp_posts.
   post_date DESC’ at line 11 for query SELECT wp_posts.ID FROM wp_posts WHERE 1
   =1 AND ( wp_posts.ID NOT IN ( SELECT object_id FROM wp_term_relationships WHERE
   term_taxonomy_id IN (2622,2625) ) ) AND (((wp_posts.post_title NOT LIKE ‘%flex%’)
   AND (wp_posts.post_excerpt NOT LIKE ‘%flex%’) AND (wp_posts.post_content NOT 
   LIKE ‘%flex%’))) AND (wp_posts.post_password = ”) AND wp_posts.post_type = ‘product’
   AND ((wp_posts.post_status = ‘publish’)) GROUP BY wp_posts.ID ORDER BY (CASE 
   WHEN THEN 2 ELSE 6 END), wp_posts.post_date DESC made by require(‘wp-blog-header.
   php’), require_once(‘wp-includes/template-loader.php’), do_action(‘template_redirect’),
   WP_Hook->do_action, WP_Hook->apply_filters, FilterEverything\Filter\Plugin->prepareEntities,
   FilterEverything\Filter\EntityManager->prepareEntitiesToDisplay, FilterEverything\
   Filter\EntityManager->getAllSetWpQueriedPostIds, WP_Query->get_postsAccording
   to to a search on phpmyadmin the ‘WHERE term_taxonomy_id IN (2622,2625)’ that
   seems to cause the issue in both errors refers to:
 * 2603 exclude-from-search product_visibility 2622
   2606 outofstock product_visibility
   2625Do I have a setting wrong?Please let me know how I can fix this issue as 
   it’s currently causing major issues due to CPU usage.
 * Thank you for your help!

Viewing 1 replies (of 1 total)

 *  Plugin Support [fesupportteam](https://wordpress.org/support/users/fesupportteam/)
 * (@fesupportteam)
 * [4 months, 1 week ago](https://wordpress.org/support/topic/database-error-428/#post-18798287)
 * Hi [@japenz](https://wordpress.org/support/users/japenz/)
 * We have checked the provided query, and the issue is caused by this part:
 *     ```wp-block-code
       ORDER BY (CASE WHEN THEN 2 ELSE 6 END)
       ```
   
 * The issue is that the `CASE WHEN` clause is missing the condition after `WHEN`,
   which is why it is causing an error.
 * However, in our plugin, filtering queries do not use and have never used `CASE
   WHEN` parameters. So either the query is being modified by separate custom code,
   or it was modified directly in the plugin.
 * Please try turning off all custom code, using the default 2025 theme, clean plugin,
   and deactivate all other plugins to check if the query changes and no longer 
   contains the `CASE WHEN` parameter.
 * Best Regards,
   Victor

Viewing 1 replies (of 1 total)

You must be [logged in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fdatabase-error-428%2F%3Foutput_format%3Dmd&locale=en_US)
to reply to this topic.

 * ![](https://ps.w.org/filter-everything/assets/icon-256x256.png?rev=3487105)
 * [Filter Everything — WordPress & WooCommerce Filters](https://wordpress.org/plugins/filter-everything/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/filter-everything/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/filter-everything/)
 * [Active Topics](https://wordpress.org/support/plugin/filter-everything/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/filter-everything/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/filter-everything/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [fesupportteam](https://wordpress.org/support/users/fesupportteam/)
 * Last activity: [4 months, 1 week ago](https://wordpress.org/support/topic/database-error-428/#post-18798287)
 * Status: resolved