根据同一行的值更新行

时间:2018-08-01 21:53:11

标签: sql oracle query-optimization

我正在尝试使用这样的请求对行进行非常简单的更新:

UPDATE MY_TABLE 
SET LINE_TX = 1000/(SELECT AMOUNT FROM MY_TABLE WHERE LINE_ID = 1 AND LINE_ORDER = 2)
WHERE LINE_ID = 1 AND LINE_ORDER = 2;

有没有办法只使用一个where子句

1 个答案:

答案 0 :(得分:1)

只需引用该列:

UPDATE MY_TABLE 
    SET LINE_TX = 1000 / AMOUNT
    WHERE LINE_ID = 1 AND LINE_ORDER = 2;