<p>I'm not sure if you can do this in the same query but you can use two queries, one for each range, and then merge them, something like this:</p>

<pre><code>{% set range1 = craft.entries({myFieldHandle: ['and', '&gt; 0', '&lt; 10']}) %}
{% set range2 = craft.entries({myFieldHandle: ['and', '&gt; 20', '&lt; 30']}) %}
{% set entries = range1 |merge(range2) %}
</code></pre>

CC BY-SA 3.0
2018-02-01T01:32:15.697Z
This is an excellent way to do it. You should query for the `ids`, and then merge those, and then query by id.
Marion Newlevant
CC BY-SA 3.0
2018-01-31T22:44:53.380Z
2018-01-31T22:44:53.380Z
Mato
<p>I currently have this working for a single range of numbers, but I can’t figure it out for multiple ranges. I currently have it set up like this for one range, and it works. <code>myFieldHandle: ['and', '&gt; 0', '&lt; 10']</code>.</p>

CC BY-SA 3.0
2018-01-31T15:04:32.353Z
Providing some of your code will help others more easily answer your question.
Dan Zuzevich
CC BY-SA 3.0
2018-01-31T22:51:47.537Z
Possible duplicate of [Complex logic on a ElementCriteriaModel parameter?](https://craftcms.stackexchange.com/questions/1948/complex-logic-on-a-elementcriteriamodel-parameter)
carlcs
<elementcriteriamodel>
Search for entries where a field value is between multiple ranges of numbers
# Search for entries where a field value is between multiple ranges of numbers

(Asked by: username_0 on 2018-01-31)

I currently have this working for a single range of numbers, but I can’t figure it out for multiple ranges. I currently have it set up like this for one range, and it works. `myFieldHandle: ['and', '> 0', '< 10']`.

**Tags:** elementcriteriamodel

> **Comments:**
> **username_1**: Providing some of your code will help others more easily answer your question.  
> **username_2**: Possible duplicate of [Complex logic on a ElementCriteriaModel parameter?](https://craftcms.stackexchange.com/questions/1948/complex-logic-on-a-elementcriteriamodel-parameter)  

---

## 1 answers

### Answer by username_3 on 2018-01-31. Score: 3

I'm not sure if you can do this in the same query but you can use two queries, one for each range, and then merge them, something like this:
{% set range1 = craft.entries({myFieldHandle: ['and', '> 0', '< 10']}) %}
{% set range2 = craft.entries({myFieldHandle: ['and', '> 20', '< 30']}) %}
{% set entries = range1 |merge(range2) %}

> **Comments:**
> **username_4**: This is an excellent way to do it. You should query for the `ids`, and then merge those, and then query by id.  

---

