manxing
manxing

Reputation: 3305

Syntax question about Mysql

all.I'm a beginner of Mysql and I have one simple question here. I want to insert a value to a specific row and column:

INSERT INTO users (doctor_id) VALUES('123') WHERE user_id='12';

But it says there's syntax error in this command, I don't know how to write it. Hope someone can help me~ Many thanks in advance!

Upvotes: 2

Views: 43

Answers (2)

Klaus Byskov Pedersen
Klaus Byskov Pedersen

Reputation: 120937

INSERT is used to insert new rows, so you cannot use a WHERE clause with inserts. What you are probably looking for is UPDATE:

UPDATE users set doctor_id = '123' where user_id = '12';

Upvotes: 3

Brad Christie
Brad Christie

Reputation: 101604

You're looking for the UPDATE command.

UPDATE users SET doctor_id='123' WHERE user_id='12';

Upvotes: 1

Related Questions