title: How do I do a semijoin using SQLAlchemy?
body: <p><a href="http://en.wikipedia.org/wiki/Relational_algebra#Semijoin" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Relational_algebra#Semijoin</a></p>
  
  <p>Let's say that I have two tables:  A and B.  I want to make a query that would work similarly to the following SQL statement using the SQLAlchemy orm:</p>
  
  <pre><code>SELECT A.*
  FROM A, B
  WHERE A.id = B.id
  AND B.type = 'some type';
  </code></pre>
  
  <p>The thing is that I'm trying to separate out A and B's logic into different places.  So I'd like to make two queries that I can define in separate places:  one where A uses B as a subquery, but only returns rows from A.  I'm sure this is fairly easy to do, but an example would be nice if someone could show me.</p>