title: Return filtered records from a returned set of data from two tables
body: <p>I have three tables:<br>
  - Venue<br>
  - Space (belongs to Venue)<br>
  - Included Space (belongs to Space)<br></p>
  
  <p>I receive the id of a Venue in the route and return all the related spaces that I know have Included Spaces(a field called num_included_spaces__c on the Space record that maintains a count of its children). Now that I have all the related parent Spaces for that Venue, I need to find all of the Included Spaces for them.</p>
  
  <p>An Included Space is still a Space, it just happens to have a parent that resides in the same table. I'm trying to turn this:</p>
  
  <p>Venue = Rockdog<br>
  - Space = Upstairs<br>
  - Space = Media Room<br>
  - Space = Courtyard<br>
  - Space = Downstairs<br>
  - Space = Front Patio<br>
  - Space = Indoor Bar<br>
  <br>
  Into this:</p>
  
  <p>Venue = Rockdog<br>
  - Space = Upstairs<br>
  -- Included Space = Media Room<br>
  -- Included Space = Courtyard<br>
  - Space = Downstairs<br>
  -- Included Space = Front Patio<br>
  -- Included Space = Indoor Bar<br>
  <br></p>
  
  <p>The Included Spaces table has belongs_to__c and space__c as fields, where belongs_to__c is the id of the parent space and space__c is the id of the child. So i'm looking to find all the Included Spaces where belongs_to_c matches the id of any @spaces returned below</p>
  
  <pre><code>@sub_spaces = Space.where("venue__c = ? AND num_included_spaces__c = ?", params[:venue],0)
  
  @spaces = Space.where("venue__c = ? AND num_included_spaces__c &gt; ?", params[:venue],0)
  </code></pre>
  
  <p>How would I write this Active Record Query for @included_spaces?</p>