我有一個有兩列的表 -x和y. x應該總是小于y我的輸出表中的值。
怎么換?我嘗試了無效的更新并引發運行時錯誤。有人可以給出正確的語法嗎?(在甲骨文中)
Update table t1 set x = (case when x<y then x else y end),
set y = (case when x<y then y else x end)

uj5u.com熱心網友回復:
使用WHERE子句只更新實際需要更新的行:
UPDATE tablename
SET x = y,
y = x
WHERE x > y;
uj5u.com熱心網友回復:
你的語法是錯誤的。UPDATE 陳述句中不應該有“TABLE” 。你有SET兩次,只想要一次
Update t1 set x = (case when x<y then x else y end),
y = (case when x<y then y else x end)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/400983.html
標籤:sql
上一篇:在一對多的連接查詢中合并行
