I have two tables with a common field I want to find all the the items(user_id's) which present in the first table but not in the second.
Table1(user_id,...)
Table2(userid,...)
Table1和Table2中的user_id是指向另一个表中同一列的外键。
最佳答案
session.query(Table1.user_id).outerjoin(Table2).filter(Table2.user_id == None)
关于python - 查找 sqlalchemy 中表之间的缺失值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17541225/