以下是我的 sqlalchemy 内连接代码。我不想选择订单表的任何列,但我也需要订单作为我的来源表。
query = db.session.query(Order, Customer.first_name, Customer.cnic_no, Item.name, Item.category)
query = query.join(Customer)
result = query.join(Item)
最佳答案
使用select_from
query = db.session.query(Customer.first_name, Customer.cnic_no, Item.name, Item.category)
query = query.select_from(Order)
query = query.join(Customer)
result = query.join(Item)
关于python - 如何在 sqlalchemy 中的 query() 中不指定的情况下使用 from table ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58843368/