[英]mysql error near where clause in simple insert statement
INSERT INTO orders_total SET `title`='Discount Coupon:', `text` = '-$40.00', `value` = '40.00' WHERE `orders_id` = '15474' AND `class`='ot_coupon
它給出以下mysql錯誤:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `orders_id` = '15474' AND `class`='ot_coupon'' at line 1
知道我在做什么錯嗎?
INSERT
語句旨在插入新行,現在更新現有行,因此WHERE
子句在INSERT
無效。 您打算進行UPDATE
。
UPDATE orders_total
SET
`title`='Discount Coupon:',
`text` = '-$40.00',
`value` = '40.00'
WHERE
`orders_id` = '15474'
AND `class`='ot_coupon'
如果打算將其作為插入而不是更新,則它不能依賴於orders_id = 15474
類的條件。 如果要插入新行,則還需要插入這些值。
INSERT INTO orders_total (`orders_id`, `class`, `title`, `text`, `value`) VALUES (15474, 'ot_coupon', 'Discount Coupon:', '-$40.00', '40.00');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.