What\'s wrong with this query:
INSERT INTO Users( weight, desiredWeight ) VALUES ( 160, 145 ) WHERE id = 1;
It works without the WHE
If you are specifying a particular record no for inserting data its better to use UPDATE
statement instead of INSERT
statement.
This type of query you have written in the question is like a dummy query.
Your Query is :-
INSERT INTO Users( weight, desiredWeight ) VALUES ( 160, 145 ) WHERE id = 1;
Here , you are specifying the id=1 , so better you use UPDATE
statement to update the existing record.It is not recommended to use WHERE
clause in case of INSERT
.You should use UPDATE
.
Now Using Update Query :-
UPDATE Users SET weight=160,desiredWeight=145 WHERE id=1;