想要按用户取出产品的价格
原 SQL 工作语句
select
pro.id as id,
pro.name as name,
pri.year1 as year1
from prices pri right outer join products pro on pri.product_id =
pro.id where user_group_id=(select user_group_id from user_relationships where user_id=2);
搞了一晚上了,还是没能成功转成 sqlalchemy 查询方法。
products = Product.query.outerjoin(Price).filter_by(user_group_id=2)
sqlalchemy 构建的句子是这样,没有返回价格信息,
SELECT
products.id AS products_id,
products.name AS products_name, products.time_created AS products_time_created, products.time_updated AS products_time_updated
FROM products LEFT OUTER JOIN prices ON
products.id = prices.product_id
WHERE prices.user_group_id = %s
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
https://www.v2ex.com/t/580500
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.