更新和嵌套选择语句?
我想更新那些一年内未购买的产品的价格。我该怎么做?
我当前的查询是:
UPDATE product
SET price = price * 0.9
WHERE date_purchase > SYSDATE - 365
AND pid IN ([How do i select the items thats not been purchased in 1year??]);
我有 2 个表:
- Product => pid、p_name 等...(pid = 产品 ID,p_name = 产品名称)
- 购买 => pid、购买日期等
I want to update prices of those products thats not been purchased by 1 year. How do I do that?
My current query is:
UPDATE product
SET price = price * 0.9
WHERE date_purchase > SYSDATE - 365
AND pid IN ([How do i select the items thats not been purchased in 1year??]);
I have 2 tables:
- Product => pid, p_name, etc... (pid = product id, p_name = product name)
- Purchase => pid, date_purchase, etc
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会选择 NOT EXISTS,因为它使要求更加透明。
当然,您会想考虑如何处理刚刚推出(例如一周前)且从未售出的产品。
I'd go with a NOT EXISTS as it makes the requirement more transparent.
of course you would want to consider what to do with products that have only been just introduced (eg a week old) and never sold.
我认为这可能会接近
I think this might come close