user393275 Asked:2020-06-10 10:16:01 +0800 CST2020-06-10 10:16:01 +0800 CST 2020-06-10 10:16:01 +0800 CST 从表中删除记录 772 需要你的帮助!需要删除 Sales 表中商品价格在 15000 到 35000 范围内的所有销售记录,请帮我实现这个请求。我的错误选择: DELETE FROM Продажи WHERE Код_товара in (Select Цена From Товар) AND [Код_товара] in (Select [Цена] From Товар) Товар.Цена BETWEEN 15000 AND 35000 sql-server 1 个回答 Voted Best Answer Nick Proskuryakov 2020-06-10T17:45:17+08:002020-06-10T17:45:17+08:00 1) 一个输入条件就够了 2) 要检查[Код_товара] in (Select * From Товар),您需要在表中具有相同的产品代码,那么[Товар],相应地搜索(Select [Код_товара] From Товар) 好吧,这里是问题的解决方案: DELETE FROM Продажи WHERE [Код_товара] in (SELECT [Код_товара] From Товар WHERE Товар.Цена BETWEEN 15000 AND 35000) 另外,正如@Akina 正确指出的那样,它会像这样更有效率: DELETE s FROM Продажи AS s JOIN Товар AS p ON s.[Код_товара] = p.[Код_товара] WHERE p.Цена BETWEEN 15000 AND 35000 至少,这是你试图做的。
1) 一个输入条件就够了
2) 要检查
[Код_товара] in (Select * From Товар),
您需要在表中具有相同的产品代码,那么[Товар]
,相应地搜索(Select [Код_товара] From Товар)
好吧,这里是问题的解决方案:
另外,正如@Akina 正确指出的那样,它会像这样更有效率:
至少,这是你试图做的。