sql语句insert into where 错误解析

sql语句中,insert into 代表得是插入一条新得数据,全新得数据,所以你这样得写法是错误得,比如:

"insert into klkl_Service_shop(name_real,registered_capital) values (%s,%s) where id = 1"

这是因为insert into 是插入全新的数据,所以id是最新的,不能加where 条件判断了。

正确的实现这个需求的方法是update ,就是更新数据,已存在的数据是更新,不存在的数据才能插入

"UPDATE klkl_Service_shop SET name_real = 'Fred' WHERE id = 1"

 

posted @ 2019-02-14 10:20  年轻人——001  阅读(8452)  评论(0编辑  收藏  举报