When doing a contact search using tags from search builder Civi throws DB syntax error, this was working before until Civi upgraded to 5.35.1

enter image description here


SELECT DISTINCT LEFT(contact_a.sort_name, 1) as sort_name\n
               FROM civicrm_contact contact_a    LEFT JOIN civicrm_entity_tag `civicrm_entity_tag-60788273efd52` ON ( `civicrm_entity_tag-60788273efd52`.entity_id = contact_a.id  AND `civicrm_entity_tag-60788273efd52`.entity_table = 'civicrm_contact')  \n
              WHERE  (  ( `civicrm_entity_tag-60788273efd52`.tag_id IN (  ) )  )  AND ( 1 ) AND (contact_a.is_deleted = 0) [nativecode=1064 ** 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 ( 1 ) AND (contact_a.is_deleted = 0)' at line 3]

1 Answer 1


Can you check if the tag you selected is a parent tag and has child tags? If yes than this is a known bug on 5.35.1 when doing a search on parent tag and is logged at https://lab.civicrm.org/dev/core/-/issues/2502 and is fixed as part of 5.38 release.

Solution(one of the below):

  1. Use 'IN' operator instead of '='.
  2. Apply patch from here.
  3. Wait for 5.38.0 release
  • Thanks for your help, the patch fixed the problem for us Apr 15, 2021 at 23:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.