<p>As per:
<a href="https://craftcms.stackexchange.com/questions/22593/query-entries-between-two-values?rq=1">Query entries between two values</a>
I found that enclosing the query string that I had with [ ] to make it a sub-array, works:</p>

<pre><code>        {% set entries = craft.entries({
            section: 'listing',
            listinglatitudenumber: ['and', '&gt;=' ~ pluginResults.latmin, '&lt;=' ~ pluginResults.latmax]
        }) %}
</code></pre>

CC BY-SA 3.0
2018-04-22T20:22:09.053Z
2018-04-22T20:22:09.053Z
ironfish
<p>You need to separate your criterias with commas</p>

<pre><code>listinglatitudenumber: 'and, ' ~  '&gt;=' ~ pluginResults.latmin ~ ', &lt;=' ~ pluginResults.latmin, 
</code></pre>

CC BY-SA 3.0
2018-04-22T19:44:26.613Z
Thanks Robin once again for your help :)
With the above syntax I get:


Internal Server Error

A hash value must be followed by a comma. Unexpected token "string" of value ", <=" ("punctuation" expected with value ",").

And I am trying to understand exactly what you mean, and trying to resolve the error, but not successful - could you explain further?
ironfish
CC BY-SA 3.0
2018-04-22T19:56:13.700Z
Of course you need to place a last comma since you are inside an object. Please read this https://craftcms.stackexchange.com/a/25774/5557 you can either separate your values via comma or you use an array from the beginning
Robin Schambach
CC BY-SA 3.0
2018-04-22T20:08:30.067Z
Thank you I will look at the examples and try to get it working :)
ironfish
CC BY-SA 3.0
2018-04-22T20:09:52.870Z
Let me know if you need further help. You simply need to convert PHP string separators `.` with twig `~`
Robin Schambach
CC BY-SA 3.0
2018-04-22T20:26:30.057Z
Thank you Robin again for your time and effort on this. :)
ironfish
CC BY-SA 4.0
2018-06-09T17:12:38.617Z
Hi Robin, At the time you provided your answer using commas, I was not able to get that to work and so I found another way to do it using [ ]. I now see that using commas would also work - I did not mean to diminish your answer. Thanks again.
ironfish
CC BY-SA 3.0
2018-04-22T19:35:24.457Z
2018-04-22T20:00:13.300Z
2018-04-22T20:00:13.300Z
Robin Schambach
<p>This works:</p>

<pre><code>            {% set entries = craft.entries({
                section: 'listing',
                listinglatitudenumber: '&gt;=' ~ pluginResults.latmin
            }) %}
</code></pre>

<p>But I need to do this:</p>

<pre><code>            {% set entries = craft.entries({
                section: 'listing',
                listinglatitudenumber: 'and', '&gt;=' ~ pluginResults.latmin, '&lt;=' ~ pluginResults.latmax
            }) %}
</code></pre>

<p>And I cannot for the life of me figure out the correct syntax for this.</p>

<p>I have been trying many different combos for the 'and' statement based on other answers I have seen in the Craft Stack Exchange but have not been successful. I have not been able to find any docs on this type of query.</p>

<p>Any help much appreciated :)</p>

<craft.entries>
ANDing criteria in craft.entries
# ANDing criteria in craft.entries

(Asked by: username_0 on 2018-04-22)

This works:
            {% set entries = craft.entries({
                section: 'listing',
                listinglatitudenumber: '>=' ~ pluginResults.latmin
            }) %}

But I need to do this:
            {% set entries = craft.entries({
                section: 'listing',
                listinglatitudenumber: 'and', '>=' ~ pluginResults.latmin, '<=' ~ pluginResults.latmax
            }) %}

And I cannot for the life of me figure out the correct syntax for this.
I have been trying many different combos for the 'and' statement based on other answers I have seen in the Craft Stack Exchange but have not been successful. I have not been able to find any docs on this type of query.
Any help much appreciated :)

**Tags:** craft.entries

---

## 2 answers

### Answer by username_0 on 2018-04-22. Score: 0 | Accepted answer

As per:
Query entries between two values
I found that enclosing the query string that I had with [ ] to make it a sub-array, works:
        {% set entries = craft.entries({
            section: 'listing',
            listinglatitudenumber: ['and', '>=' ~ pluginResults.latmin, '<=' ~ pluginResults.latmax]
        }) %}


---

### Answer by username_1 on 2018-04-22. Score: 1

You need to separate your criterias with commas
listinglatitudenumber: 'and, ' ~  '>=' ~ pluginResults.latmin ~ ', <=' ~ pluginResults.latmin,

> **Comments:**
> **username_0**: Thanks Robin once again for your help :) With the above syntax I get:   Internal Server Error  A hash value must be followed by a comma. Unexpected token "string" of value ", <=" ("punctuation" expected with value ",").  And I am trying to understand exactly what you mean, and trying to resolve the error, but not successful - could you explain further?  
> **username_1**: Of course you need to place a last comma since you are inside an object. Please read this https://craftcms.stackexchange.com/a/25774/5557 you can either separate your values via comma or you use an array from the beginning  
> **username_0**: Thank you I will look at the examples and try to get it working :)  
> **username_1**: Let me know if you need further help. You simply need to convert PHP string separators `.` with twig `~`  
> **username_0**: Thank you Robin again for your time and effort on this. :)  
> **username_0**: Hi Robin, At the time you provided your answer using commas, I was not able to get that to work and so I found another way to do it using [ ]. I now see that using commas would also work - I did not mean to diminish your answer. Thanks again.  

---

