开发者

Error 1064 in mysql

开发者 https://www.devze.com 2023-03-07 10:50 出处:网络
Why does the following show a mysql 1064 error? I have a the following table: daily_note (id, time (timestamp), rate_id, note )

Why does the following show a mysql 1064 error?

I have a the following table:

daily_note (id, time (timestamp), rate_id, note )

On this table I'm executing the following 开发者_如何学编程insert:

INSERT INTO daily_note (note)
VALUES ('this is a note')
WHERE rate_id = 37
AND time > '2011-05-22 00:00:00'

Cannot perform insert:

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 rate_id = 37 AND time > '2011-05-22 00:' at line 3'


You can't INSERT using a WHERE statement. If you want to modify existing records based on some condition/criteria, use an UPDATE statement instead of INSERT.


INSERT with WHERE makes no sense.

INSERT creates new rows, whereas WHERE specifies criteria for retrieving/updating existing rows.

Read up about the syntax and meaning of the statement that you're trying to use, before trying to use it.


Code should read:

UPDATE DAILY_NOTE
SET field='this is a not'
WHERE rate_id = 37
AND time > '2011-05-22 00:00:00'
0

精彩评论

暂无评论...
验证码 换一张
取 消