title: sqlalchemy - join child table with 2 conditions
body: <p>How to add 2 conditions to the ON clause when you join 2 tables. 
  I have 3 three tables in hierarchy each with the deleted flag. I have to join all these table in a single query and filter based on deleted flag also. Currently the conditions gets added to the where clause of the query, which does not filter the deleted records.
  It needs to be added to the ON clause. Please suggest.</p>
  
  <p>My current query is as follows:</p>
  
  <pre><code>result = session.query(Host).filter(and_(Host.id.in_(ids), Host.deleted == False)).\
      join(Switch).filter(Switch.deleted == False).\
      join(Port).filter(Port.deleted == False).\
      options(joinedload('switches')).\
      options(joinedload('ports')).\
      all()
  </code></pre>
  
  <p>Thankyou</p>