-5
create table wallet(userId int,coin int,primary key(userId));我如何修改這個sql執行?
更新錢包SET硬幣=硬幣 - (最少(選擇硬幣從錢包其中userId = 101,500))其中userId = 101;
create table wallet(userId int,coin int,primary key(userId));我如何修改這個sql執行?
更新錢包SET硬幣=硬幣 - (最少(選擇硬幣從錢包其中userId = 101,500))其中userId = 101;
一個
update wallet
SET coin=coin-(least(coin,500))
where userId=101;
或其他可能
update wallet
SET coin=case when coin < 500 then 0 else coin-500 end
where userId=101;
你想要做什麼?只是運行它? – Steven
我不認爲這是一個與「錢包」和「硬幣」工作的人應該問的那種問題。 – user3791372
這個SQL有語法錯誤,但我無法弄清楚。 –