MySQL Insert Where query

前端 未结 27 2172
悲&欢浪女
悲&欢浪女 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:52

    It depends on the situation INSERT can actually have a where clause.

    For example if you are matching values from a form.

    Consider INSERT INTO Users(name,email,weight, desiredWeight) VALUES (fred,bb@yy.com,160,145) WHERE name != fred AND email != bb@yy.com
    

    Makes sense doesn't it?

提交回复
热议问题