Answers.Body: <p>I finally found something that worked after trying various methods:</p>
  <pre><code>{% set allEntries = query.all() %}
  
      {% set allResults = allEntries|filter(entry =&gt;
          entry.associatedBusiness == queryParam or
          entry.businessVertical2 == queryParam or
          entry.businessVertical3 == queryParam
      ) %}
  
      {% set currentPage = craft.app.request.pageNum %}
      {% set total = allResults|length %}
  
      {% set offset = (currentPage - 1) * pageSize %}
      {% set pageEntries = allResults|slice(offset, pageSize) %}
  
      {% set pageInfo = {
          first: 1,
          last: ceil(total / pageSize),
          total: total,
          currentPage: currentPage,
          limit: pageSize,
          offset: offset
      } %}
  </code></pre>
  <p>and if you want to add paging you can do</p>
  <pre><code>{% if pageInfo.total &gt; pageSize %}
                      &lt;div class=&quot;paginationHolder&quot;&gt;
                          &lt;ul class=&quot;pagination&quot;&gt;
                              {% if currentPage &gt; 1 %}
                                  &lt;li&gt;&lt;a href=&quot;{{ url(craft.app.request.pathInfo, {page: currentPage-1}) }}&quot;&gt;Previous&lt;/a&gt;&lt;/li&gt;
                              {% endif %}
                              
                              {% if currentPage &lt; pageInfo.last %}
                                  &lt;li&gt;&lt;a href=&quot;{{ url(craft.app.request.pathInfo, {page: currentPage+1}) }}&quot;&gt;Next&lt;/a&gt;&lt;/li&gt;
                              {% endif %}
                          &lt;/ul&gt;
                      &lt;/div&gt;
                  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-11-14T11:58:00.777Z
Answers.Text: Not sure I'd recommend this approach - better to get the stuff you need up front rather than fetching everything and then filtering it. Have you checked Yii's documentation on `where`? https://www.yiiframework.com/doc/api/2.0/yii-db-querytrait#where()-detail - You can add this in a Craft element query something like this: `craft.entries.where(['or', 'fieldColumnName1 = "something"', 'fieldColumnName2 = "another"']).all()`
Answers.UserDisplayName: James Smith
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-11-14T01:11:31.513Z
Answers.LastActivityDate: 2024-11-14T01:13:07.000Z
Answers.LastEditDate: 2024-11-14T01:13:07.000Z
Answers.UserDisplayName: Hector Ochoa
Body: <p>I'm currently querying entries successfully like so for the <code>associatedBusiness</code>
  field:</p>
  <p><code>{% set query = query.businessVertical(queryParam) %}</code></p>
  <p>However I have two other dropdown fields that I would like to check against:</p>
  <p><a href="https://i.sstatic.net/c9R8mGgY.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/c9R8mGgY.png" alt="enter image description here" /></a></p>
  <p>I tries this but doesn't seem to work:</p>
  <p><code>{% set query = query.search('businessVertical:' ~ queryParam ~ ' OR  businessVertical2:' ~ queryParam ~ ' OR  businessVertical3:' ~ queryParam) %}</code></p>
  <p>Not sure of any other ways to write this syntax with Craft3</p>
  
Tags: <craft3><query>
Title: Query entries for multiple dropdown field values
ThreadText: # Query entries for multiple dropdown field values
  
  (Asked by: username_0 on 2024-11-13)
  
  I'm currently querying entries successfully like so for the `associatedBusiness`
  field:
  
  `{% set query = query.businessVertical(queryParam) %}`
  
  However I have two other dropdown fields that I would like to check against:
  
  [![enter image description here](https://i.sstatic.net/c9R8mGgY.png)](https://i.sstatic.net/c9R8mGgY.png)
  
  I tries this but doesn't seem to work:
  
  `{% set query = query.search('businessVertical:' ~ queryParam ~ ' OR businessVertical2:' ~ queryParam ~ ' OR businessVertical3:' ~ queryParam) %}`
  
  Not sure of any other ways to write this syntax with Craft3
  
  **Tags:** craft3, query
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2024-11-14. Score: 0
  
  I finally found something that worked after trying various methods:
  
  ```
  {% set allEntries = query.all() %}
  
      {% set allResults = allEntries|filter(entry =>
          entry.associatedBusiness == queryParam or
          entry.businessVertical2 == queryParam or
          entry.businessVertical3 == queryParam
      ) %}
  
      {% set currentPage = craft.app.request.pageNum %}
      {% set total = allResults|length %}
  
      {% set offset = (currentPage - 1) * pageSize %}
      {% set pageEntries = allResults|slice(offset, pageSize) %}
  
      {% set pageInfo = {
          first: 1,
          last: ceil(total / pageSize),
          total: total,
          currentPage: currentPage,
          limit: pageSize,
          offset: offset
      } %}
  
  ```
  
  and if you want to add paging you can do
  
  ```
  {% if pageInfo.total > pageSize %}
                      <div class="paginationHolder">
                          <ul class="pagination">
                              {% if currentPage > 1 %}
                                  <li><a href="{{ url(craft.app.request.pathInfo, {page: currentPage-1}) }}">Previous</a></li>
                              {% endif %}
                              
                              {% if currentPage < pageInfo.last %}
                                  <li><a href="{{ url(craft.app.request.pathInfo, {page: currentPage+1}) }}">Next</a></li>
                              {% endif %}
                          </ul>
                      </div>
                  {% endif %}
  
  ```
  
  > **Comments:**
  > **username_1**: Not sure I'd recommend this approach - better to get the stuff you need up front rather than fetching everything and then filtering it. Have you checked Yii's documentation on `where`? https://www.yiiframework.com/doc/api/2.0/yii-db-querytrait#where()-detail - You can add this in a Craft element query something like this: `craft.entries.where(['or', 'fieldColumnName1 = "something"', 'fieldColumnName2 = "another"']).all()`  
  
  ---
  
  