Replies: 0
Hello. We have a dev site that has a search feature in the header wherein the user can search the whole site or just products (managed by Woocommerce). If I select to search only products, there are always zero results. (If I search the whole site, product results are given along with non-product results.) Checking the PHP error logs, I see this SQL error:
WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘)) AND (
( wp_postmeta.meta_key = ‘_visibility’ AND CAST(wp_postmeta.meta_val’ at line 3 for query SELECT COUNT(DISTINCT(relevanssi.doc)) FROM wp_relevanssi AS relevanssi
INNER JOIN wp_postmeta ON ( relevanssi.doc = wp_postmeta.post_id ) WHERE (relevanssi.term LIKE ‘stain%’
OR relevanssi.term_reverse LIKE CONCAT(REVERSE(‘stain’), ‘%’)) AND relevanssi.doc NOT IN (SELECT DISTINCT(tr.object_id) FROM wp_term_relationships AS tr WHERE tr.term_taxonomy_id IN ()) AND (
( wp_postmeta.meta_key = ‘_visibility’ AND CAST(wp_postmeta.meta_value AS CHAR) IN (‘visible’,’search’) )
) AND (
relevanssi.doc IN (
SELECT DISTINCT(posts.ID) FROM wp_posts AS posts
WHERE posts.post_type IN (‘product’)
)
) made by require(‘wp-blog-header.php’), wp, WP->main, WP->query_posts, WP_Query->query, WP_Query->get_posts, apply_filters_ref_array, call_user_func_array, relevanssi_query, relevanssi_do_query, relevanssi_search, relevanssi_search
It seems to not like the empty parentheses in “WHERE tr.term_taxonomy_id IN ()”
We are using MariaDB 10.1 for our database, but I also checked the syntax via https://www.piliapp.com/mysql-syntax-check/ to make sure that indeed the syntax is wrong, and not that MariaDB 10.1 is faulty in handling this statement.
Is there a solution to this SQL error? (I already have the most recent version of Relevanssi.)