擅长:python、mysql、java
<p>在SQL中,<code>A RIGHT OUTER JOIN B</code>等同于<code>B LEFT OUTER JOIN A</code>。因此,从技术上讲,不需要在<code>RIGHT OUTER JOIN</code>API中——通过切换目标的位置“selectable”和连接的位置“selectable”,也可以做到这一点。SQL炼金术为此提供了一个API:</p>
<pre><code># this **fictional** API:
query(A).join(B, right_outer_join=True) # right_outer_join doesn't exist in SQLA!
# can be implemented in SQLA like this:
query(A).select_entity_from(B).join(A, isouter=True)
</code></pre>
<p>请参阅SQLA<a href="https://docs.sqlalchemy.org/en/latest/orm/query.html#sqlalchemy.orm.query.Query.join" rel="nofollow noreferrer">Query.join() doc</a>,控制从“</em>加入什么”部分。</p>