爲什麼這發生在我身上?我不知道爲什麼我的語法得到錯誤的,當我想讓如果有條件的話在我的SQL我的語法錯誤,當我想如果條件sql
IF quantity <= 0
UPDATE tbl_books
SET status = 'Not Available'
ELSE
UPDATE tbl_books
SET quantity = quantity -1
WHERE isbn = 'tes1'
我得到了這樣的錯誤
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'IF 'quantity' <= 0 UPDATE tbl_books SET status = 'Not Available' ELSE UPDA' at line 1
是'status'默認設置爲'Available'? – toonice
是的,它是@toonice – Onosibiw