im trying to insert data into a particular row in the database, but i mysql is saying this is an error:
INSERT INTO开发者_StackOverflow user (rep, course) VALUES('5', 'computer science') WHERE user='2'
UPDATE user
SET rep = '5', course = 'computer science'
WHERE user = '2'
Link to docs.
You might want to UPDATE instead,
UPDATE user set rep='5', course='computer science' WHERE user='2'
INSERT statement should not come with WHERE clause.
INSERT
statement can not be used with WHERE
clause because you are going to insert a new row using INSERT
so how could you check any condition over the row which even doesn't exits ?
That's the main reason you can't use WHERE
clause with INSERT
statement....
use: UPDATE table-name SET column=val WHERE some cont
Command if you need to update existing row....
精彩评论