使用mysql查询计算价格
大师们!我被困住了。目录项目的价格取决于其数量。这里的表格示例:
items: just item definitions
-------------------------
item_id | item_title
-------------------------
1 | "sample item"
2 | "another item"
items_prices: prices dependent to item quantity.
Less price taken for more quantity of item
----------------------------
item_id | quantity | price
----------------------------
1 | 1 | 100
1 | 5 | 80
1 | 10 | 60
2 | 1 | 120
2 | 3 | 100
cart
-------------------
item_id | quantity
-------------------
1 | 20
2 | 2
是否可以通过单个查询获取当前的购物车成本?
gurus! I am stuck. Catalog items have prices dependent to its quantity. Here example of tables:
items: just item definitions
-------------------------
item_id | item_title
-------------------------
1 | "sample item"
2 | "another item"
items_prices: prices dependent to item quantity.
Less price taken for more quantity of item
----------------------------
item_id | quantity | price
----------------------------
1 | 1 | 100
1 | 5 | 80
1 | 10 | 60
2 | 1 | 120
2 | 3 | 100
cart
-------------------
item_id | quantity
-------------------
1 | 20
2 | 2
Is it possible to get current cart cost with single query?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
再次连接回 items_price 可以让我们过滤掉任何数量较多但仍符合我们标准的情况。这应该接近我们想要的
The join back onto items_price again lets us filter out any cases where there is a greater quantity which still meets our criteria. This should be getting close to what we're after