Answers.Body: <p>I think this is what you mean:</p>
  
  <pre><code>{% set sectionBEntries = craft.entries.section('B').authorId(currentUser.id) %}
  
  {# 'relatedTo' works both ways, so we can use sectionBEntries 
      as input for relatedTo to get all section A entries that have 
      a relation to one of the section B entries by currentUser #}
  {% set sectionAEntries = craft.entries.section('A').relatedTo(sectionBEntries) %}
  
  {% for entry in sectionAEntries %}
      {{ entry.title }}
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-27T19:16:29.297Z
Answers.Text: That's exactly what I'm looking for. Had no idea that you could use groups of entries in relatedTo like that, 'doh. Many thanks!
Answers.UserDisplayName: Graham
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-27T18:44:00.523Z
Answers.LastActivityDate: 2014-11-27T18:44:00.523Z
Answers.UserDisplayName: Paul
Body: <p>The setup:</p>
  
  <p><strong>Section A</strong> <em>(entries I want to list)</em></p>
  
  <p><strong>Section B</strong></p>
  
  <ul>
  <li>entries field (related to 1 entry from SectionA)</li>
  </ul>
  
  <p><strong>My goal is to list all entries from Section A, that are related to an entry in Section B  authored by the currentUser.</strong></p>
  
  <p>Right now what I'm doing is looping through all entries in Section B authored by the current user and querying/displaying the entry related to it, but it's way too inefficient and eats up a lot of database queries. Was hoping there's a more efficient way of doing this.</p>
  
  <p>Not sure whether or not there's a way to achieve this sort of relation via a complex relatedTo or if I need to go another route.</p>
  
  <p>Can provide additional information/clarification if anything is unclear.</p>
  
  <p>Thanks</p>
  
Tags: <entries><relations>
Title: Listing all entries in one section related to entries written by currentUser in another section
ThreadText: # Listing all entries in one section related to entries written by currentUser in another section
  
  (Asked by: username_0 on 2014-11-27)
  
  The setup:
  
  **Section A** *(entries I want to list)*
  
  **Section B**
  
  * entries field (related to 1 entry from SectionA)
  
  **My goal is to list all entries from Section A, that are related to an entry in Section B authored by the currentUser.**
  
  Right now what I'm doing is looping through all entries in Section B authored by the current user and querying/displaying the entry related to it, but it's way too inefficient and eats up a lot of database queries. Was hoping there's a more efficient way of doing this.
  
  Not sure whether or not there's a way to achieve this sort of relation via a complex relatedTo or if I need to go another route.
  
  Can provide additional information/clarification if anything is unclear.
  
  Thanks
  
  **Tags:** entries, relations
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-11-27. Score: 8 | Accepted answer
  
  I think this is what you mean:
  
  ```
  {% set sectionBEntries = craft.entries.section('B').authorId(currentUser.id) %}
  
  {# 'relatedTo' works both ways, so we can use sectionBEntries 
      as input for relatedTo to get all section A entries that have 
      a relation to one of the section B entries by currentUser #}
  {% set sectionAEntries = craft.entries.section('A').relatedTo(sectionBEntries) %}
  
  {% for entry in sectionAEntries %}
      {{ entry.title }}
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: That's exactly what I'm looking for. Had no idea that you could use groups of entries in relatedTo like that, 'doh. Many thanks!  
  
  ---
  
  