MySQL Insert Where query

前端 未结 27 2148
悲&欢浪女
悲&欢浪女 2020-11-22 06:16

What\'s wrong with this query:

INSERT INTO Users( weight, desiredWeight ) VALUES ( 160, 145 ) WHERE id = 1;

It works without the WHE

27条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-22 06:48

    I think that the correct form to insert a value on a specify row is:

    UPDATE table SET column = value WHERE columnid = 1
    

    it works, and is similar if you write on Microsoft SQL Server

    INSERT INTO table(column) VALUES (130) WHERE id = 1;
    

    on mysql you have to Update the table.

提交回复
热议问题