SELECT
*
FROM
"woocommerce_shoporder"
WHERE
shop_id = '5'
AND transaction_id != ''
AND ( order_type IS NULL OR order_type != 'presto_mart_child_order' )
AND NOT fulfillment_status = 'fulfilled'
AND EXISTS ( SELECT * FROM "woocommerce_shoporderitem" WHERE woocommerce_shoporderitem.order_id = woocommerce_shoporder.ID AND woocommerce_shoporderitem.sku_id IS NOT NULL AND woocommerce_shoporderitem.is_retail != TRUE )
AND NOT (
(
SELECT COUNT
( item.* )
FROM
woocommerce_shoporderitem item
LEFT JOIN woocommerce_externalorder ON item.ID = woocommerce_externalorder.shop_order_item_id
WHERE
item.sku_id IS NOT NULL
AND item.is_retail != TRUE
AND item.order_id = woocommerce_shoporder.ID
AND woocommerce_externalorder.status IN ( 3, 4 )
) = ( SELECT COUNT ( item2.* ) FROM woocommerce_shoporderitem item2 WHERE item2.order_id = woocommerce_shoporder.ID AND item2.sku_id IS NOT NULL )
)
求助,如何把以上 SQL 语句翻译为 Django ORM 形式的查询
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.