mysql Update subquery Table is Specified twice

Clash Royale CLAN TAG#URR8PPPmysql Update subquery Table is Specified twice
i try this subquery to decerese 1 i my quantity every time i execute this query , i think it will work on sqlServer but why its not working on mysql.
im getting this error
Table 't1' is specified twice, both as a target for 'UPDATE' and as a separate source for data
heres my code
Update tblbooks AS t1 set t1.Quantity = (Select t2.Quantity-1 from tblbooks AS t2 where t2.BookId = 123) where t1.BookId = 123
1 Answer
1
You don't need the subquery there - you can reassign a calculation on a column back to the same column:
UPDATE tblbooks
SET Quantity = Quantity - 1
WHERE BookId = 123
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
hahaha,i feel bad for me ,thank you
– Ivan
2 mins ago