<p>You could use the <a href="http://buildwithcraft.com/docs/templating/filters#without" rel="nofollow"><code>without</code></a> filter for this:</p>

<pre><code>{% set entryParams = {
    section: mySection1
} %}

{% set relationParams = {
    sourceElement: mySection2,
    field: myEntriesField
} %}

{% set entriesWithRelation = craft.entries(params).relatedTo(relationParams).find() %}
{% set entriesWithoutRelation = craft.entries(params)|without(entriesWithRelation) %}
</code></pre>

CC BY-SA 3.0
2014-12-05T13:54:08.307Z
Without getting to the second without part, the  entriesWithRelation setting with relatedTo outputs every single entry in the system regardless of section.

Looking at the docs http://buildwithcraft.com/docs/relations I'm certain that what I'm trying to do is relatively easy, which in the first instance is:

if any mySection1 entries have been made a relation in mySection2 list them here...
Simon Clayson
CC BY-SA 3.0
2014-12-05T13:59:43.733Z
You probably have a lot of different kind of relations, that can make it necessary to further narrow down the query, @Simon. Will update the code...
carlcs
CC BY-SA 3.0
2014-12-05T17:46:54.987Z
There are about 3 relationship fields in mySection2 entries indeed.
Simon Clayson
CC BY-SA 3.0
2014-12-05T21:40:51.150Z
Did you get this to work now, @Simon? By specifying the element and the field of your relation you should probably be good!
carlcs
CC BY-SA 3.0
2014-12-07T07:49:47.940Z
Got halfway there - will update later thanks.
Simon Clayson
CC BY-SA 3.0
2014-12-04T23:50:40.487Z
2014-12-05T14:00:23.480Z
2014-12-05T14:00:23.480Z
carlcs
<p>I have a list of entries and I would like to filter them into 2 lists.</p>

<ol>
<li>Entries that have been made a relation in another section</li>
<li>Entries that have NOT been made a relation in another section</li>
</ol>

<p>I thought about tackling this the other way round and listing the section with the relations but some entires are related multiple times, so and the titles in the list get repeated multiple times. Unless this can filter out the duplicates, but it starts to get messy at this point. </p>

<p>Ideas welcome thanks.</p>

<entries><relations>
List Entries in a section that are referenced as a relation in another
# List Entries in a section that are referenced as a relation in another

(Asked by: username_0 on 2014-12-04)

I have a list of entries and I would like to filter them into 2 lists.

1. Entries that have been made a relation in another section
2. Entries that have NOT been made a relation in another section

I thought about tackling this the other way round and listing the section with the relations but some entires are related multiple times, so and the titles in the list get repeated multiple times. Unless this can filter out the duplicates, but it starts to get messy at this point.

Ideas welcome thanks.

**Tags:** entries, relations


---

## 1 answers

### Answer by username_1 on 2014-12-04. Score: 1

You could use the without filter for this:
{% set entryParams = {
    section: mySection1
} %}

{% set relationParams = {
    sourceElement: mySection2,
    field: myEntriesField
} %}

{% set entriesWithRelation = craft.entries(params).relatedTo(relationParams).find() %}
{% set entriesWithoutRelation = craft.entries(params)|without(entriesWithRelation) %}

> **Comments:**
> **username_0**: Without getting to the second without part, the  entriesWithRelation setting with relatedTo outputs every single entry in the system regardless of section.  Looking at the docs http://buildwithcraft.com/docs/relations I'm certain that what I'm trying to do is relatively easy, which in the first instance is:  if any mySection1 entries have been made a relation in mySection2 list them here...  
> **username_1**: You probably have a lot of different kind of relations, that can make it necessary to further narrow down the query, @Simon. Will update the code...  
> **username_0**: There are about 3 relationship fields in mySection2 entries indeed.  
> **username_1**: Did you get this to work now, @Simon? By specifying the element and the field of your relation you should probably be good!  
> **username_0**: Got halfway there - will update later thanks.  

---

