<p>You might have seen <a href="https://docs.craftcms.com/v2/relations.html#the-relatedto-param" rel="nofollow noreferrer">Passing Multiple Relation Criteria</a>  in the docs</p>

<pre><code>{% set entries = craft.entries.section('flightcompany').relatedTo([
    'and',
    { targetElement: models, field: 'partsModels.model' },
    { targetElement: parts, field: 'partsModels.part' }
]).all() %}
</code></pre>

<p>You can as well take a look at the <a href="https://docs.craftcms.com/v3/element-queries.html#param-value-syntax" rel="nofollow noreferrer">Db::parseParam</a> the <code>and|or</code> syntax is the same for this field</p>

CC BY-SA 4.0
2018-05-10T22:30:13.170Z
Perfect! Thanks again Robin, you really have helped me out again :)
Vin
CC BY-SA 4.0
2018-05-12T19:21:03.010Z
It seems I tried this and it came back with no results.  I am trying to get the results between 2 matrix fields.  Right now I am using conditionals and using .limit(25) and with the conditionals in the matrix loop I sometimes only get 4-5 results.  So would be best to get them at the main entries loop.
Vin
CC BY-SA 4.0
2018-05-12T19:38:00.300Z
Sorry but it's really difficult to understand your explanation. What do you want exactly? You won't fetch matrix blocks with your query. You'll receive elements of type entry. The code above works. I've used it many times without issues
Robin Schambach
CC BY-SA 4.0
2018-05-12T21:42:07.703Z
I am sure it does, not working for me, it's me not you.  I am trying to make sure that each of those conditions/data matches.  So models = cessna and parts = front propeller in flightcompany limit 25 records.  Those records exist in the extries but for some reason it works with just searching parts or models but not used together with 'and'.
Vin
CC BY-SA 4.0
2018-05-10T19:29:45.697Z
2018-05-18T23:26:01.507Z
2018-05-18T23:26:01.507Z
Robin Schambach
<p>I am trying to accomplish targeting but wondering if there is a way to combine these two? I took a look around and in the Craft 3 docs but I am a bit turned around on this, really would appreciate some help with it.</p>

<pre><code>{% set parts = craft.categories.group('part').slug( urlSlug2 ) %}
{% set models = craft.categories.group('model').slug( urlSlug3 ) %}

{% set entries1 = craft.entries.section('flightcompany').relatedTo({
    targetElement: parts, 
    field: 'partsModels.part' 
}).limit(5).all() %}

{% set entries2 = craft.entries.section('flightcompany').relatedTo({
    targetElement: models, 
    field: 'partsModels.model' 
}).limit(5).all() %}
</code></pre>

<craft3><relations>
Combining Multiple Relation
# Combining Multiple Relation

(Asked by: username_0 on 2018-05-10)

I am trying to accomplish targeting but wondering if there is a way to combine these two? I took a look around and in the Craft 3 docs but I am a bit turned around on this, really would appreciate some help with it.
{% set parts = craft.categories.group('part').slug( urlSlug2 ) %}
{% set models = craft.categories.group('model').slug( urlSlug3 ) %}

{% set entries1 = craft.entries.section('flightcompany').relatedTo({
    targetElement: parts, 
    field: 'partsModels.part' 
}).limit(5).all() %}

{% set entries2 = craft.entries.section('flightcompany').relatedTo({
    targetElement: models, 
    field: 'partsModels.model' 
}).limit(5).all() %}

**Tags:** craft3, relations

---

## 1 answers

### Answer by username_1 on 2018-05-10. Score: 5 | Accepted answer

You might have seen Passing Multiple Relation Criteria  in the docs
{% set entries = craft.entries.section('flightcompany').relatedTo([
    'and',
    { targetElement: models, field: 'partsModels.model' },
    { targetElement: parts, field: 'partsModels.part' }
]).all() %}

You can as well take a look at the Db::parseParam the and|or syntax is the same for this field

> **Comments:**
> **username_0**: Perfect! Thanks again Robin, you really have helped me out again :)  
> **username_0**: It seems I tried this and it came back with no results.  I am trying to get the results between 2 matrix fields.  Right now I am using conditionals and using .limit(25) and with the conditionals in the matrix loop I sometimes only get 4-5 results.  So would be best to get them at the main entries loop.  
> **username_1**: Sorry but it's really difficult to understand your explanation. What do you want exactly? You won't fetch matrix blocks with your query. You'll receive elements of type entry. The code above works. I've used it many times without issues  
> **username_0**: I am sure it does, not working for me, it's me not you.  I am trying to make sure that each of those conditions/data matches.  So models = cessna and parts = front propeller in flightcompany limit 25 records.  Those records exist in the extries but for some reason it works with just searching parts or models but not used together with 'and'.  

---

