```sql
UPDATE order_items AS U1
INNER JOIN
(SELECT
X.provider_id,
X.product_id,
X.order_id,
X.model_id,
Y.qty,
(SELECT
M.price * N.discount
FROM
quotation AS M
LEFT JOIN quotation_discount N ON M.provider_id = N.provider_id
AND M.product_id = N.product_id
WHERE
M.model_id = X.model_id
AND M.provider_id = X.provider_id
AND Y.qty BETWEEN N.min_quantity AND N.max_quantity) AS price
FROM
(SELECT
A.model_id, A.order_id, B.provider_id, C.product_id
FROM
order_inquiry_items A
LEFT JOIN order_inquiry B ON A.order_inquiry_id =
B.id LEFT JOIN product_model C ON A.model_id =
C.id WHERE
A.order_id = 23 AND B.provider_id = 14
AND C.product_id = 1) AS X
LEFT JOIN order_items Y ON X.model_id = Y.model_id
AND X.model_id = Y.model_id) AS U2 ON U1.order_id = U2.order_id
AND U1.model_id = U2.model_id
SET
U1.price = U2.price
```
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
https://www.v2ex.com/t/228069
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.