Answers.Body: <p>The problem here is <code>join(&quot;,&quot;)</code> as it is returning a <code>string</code> of your values, something like <code>&quot;123, 456&quot;</code> instead of a comma separated list of <code>int</code> as you expect.</p>
  <p>Try this:</p>
  <pre class="lang-twig prettyprint-override"><code>{# Create an array starting in 'and` #}
  {% set relatedTags = ['and'] %}
  
  {# Merge your ids in your relatedTags array #}
  {% set blogQ = blogQ.blogTags(relatedTags | merge(blogTag)) %}
  </code></pre>
  <p>See documentation for the <a href="https://craftcms.com/docs/3.x/dev/filters.html#merge" rel="nofollow noreferrer"><code>merge</code> filter</a>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-01T09:03:30.117Z
Answers.Text: Thank you! Makes sense now.  
  So the query I was trying would actually look like:  
  `{% set blogQ = blogQ.blogTags(['and',"2291,2290"]) %}`?
Answers.UserDisplayName: Jaytrix
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-02T07:24:45.397Z
Answers.Text: Yes! That's it :)
Answers.UserDisplayName: Oli
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-01T06:54:21.973Z
Answers.LastActivityDate: 2022-06-01T06:54:21.973Z
Answers.UserDisplayName: Oli
Body: <p>I'm struggling to get a <code>and</code> entry query to work - it seems to be stuck on <code>or</code>.</p>
  <p>Query is <code>{% set blogQ = blogQ.blogTags(['and', blogTag|join(&quot;,&quot;)]) %}</code> where <code>blogTag</code> is <code>[2291,2290]</code> in this case. This would translate to <code>{% set blogQ = blogQ.blogTags(['and',2291,2290]) %}</code></p>
  <p>In this instance I get 0 results.</p>
  <p>If I change to use <code>{% set blogQ = blogQ.blogTags(blogTag) %}</code> then I'll get entries that have the tag id of 2291 OR 2290</p>
  
Tags: <craft3><entries><query><tags>
Title: Entry query on field using the `and` parameter
ThreadText: # Entry query on field using the `and` parameter
  
  (Asked by: username_0 on 2022-05-31)
  
  I'm struggling to get a `and` entry query to work - it seems to be stuck on `or`.
  
  Query is `{% set blogQ = blogQ.blogTags(['and', blogTag|join(",")]) %}` where `blogTag` is `[2291,2290]` in this case. This would translate to `{% set blogQ = blogQ.blogTags(['and',2291,2290]) %}`
  
  In this instance I get 0 results.
  
  If I change to use `{% set blogQ = blogQ.blogTags(blogTag) %}` then I'll get entries that have the tag id of 2291 OR 2290
  
  **Tags:** craft3, entries, query, tags
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-06-01. Score: 1 | Accepted answer
  
  The problem here is `join(",")` as it is returning a `string` of your values, something like `"123, 456"` instead of a comma separated list of `int` as you expect.
  
  Try this:
  
  ```twig
  {# Create an array starting in 'and` #}
  {% set relatedTags = ['and'] %}
  
  {# Merge your ids in your relatedTags array #}
  {% set blogQ = blogQ.blogTags(relatedTags | merge(blogTag)) %}
  
  ```
  
  See documentation for the [`merge` filter](https://craftcms.com/docs/3.x/dev/filters.html#merge).
  
  > **Comments:**
  > **username_0**: Thank you! Makes sense now.   So the query I was trying would actually look like:   `{% set blogQ = blogQ.blogTags(['and',"2291,2290"]) %}`?  
  > **username_1**: Yes! That's it :)  
  
  ---
  
  