Answers.Body: <p>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 <a href="https://lab.civicrm.org/dev/core/-/issues/2502" rel="nofollow noreferrer">https://lab.civicrm.org/dev/core/-/issues/2502</a> and is fixed as part of 5.38 release.</p>
  <p>Solution(one of the below):</p>
  <ol>
  <li>Use 'IN' operator instead of '='.</li>
  <li>Apply patch from <a href="https://patch-diff.githubusercontent.com/raw/civicrm/civicrm-core/pull/19961.patch" rel="nofollow noreferrer">here</a>.</li>
  <li>Wait for 5.38.0 release</li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-04-15T23:12:15.007Z
Answers.Text: Thanks for your help, the patch fixed the problem for us
Answers.UserDisplayName: FullStack-Dev
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-04-15T18:19:45.887Z
Answers.LastActivityDate: 2021-04-15T18:19:45.887Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>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</p>
  <p><a href="https://i.sstatic.net/T30PZ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/T30PZ.png" alt="enter image description here" /></a></p>
  <p>Error:</p>
  <pre><code>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 = &amp;#039;civicrm_contact&amp;#039;)  \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 &amp;#039;) )  )  AND ( 1 ) AND (contact_a.is_deleted = 0)&amp;#039; at line 3]
          &amp;quot;&amp;quot;&amp;quot;
  </code></pre>
  
Tags: <tags><search-builder>
Title: Unable to do a search using tag
ThreadText: # Unable to do a search using tag
  
  (Asked by: username_0 on 2021-04-15)
  
  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](https://i.sstatic.net/T30PZ.png)](https://i.sstatic.net/T30PZ.png)
  
  Error:
  
  ```
  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 = &#039;civicrm_contact&#039;)  \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 &#039;) )  )  AND ( 1 ) AND (contact_a.is_deleted = 0)&#039; at line 3]
          &quot;&quot;&quot;
  
  ```
  
  **Tags:** tags, search-builder
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-04-15. Score: 0
  
  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](https://patch-diff.githubusercontent.com/raw/civicrm/civicrm-core/pull/19961.patch).
  3. Wait for 5.38.0 release
  
  > **Comments:**
  > **username_0**: Thanks for your help, the patch fixed the problem for us  
  
  ---
  
  