-
mysql insert update语句执行这条语句,会帮你自动判断 数据库中是否有与你要插入的记录重复主键,有则更新,没有就插入格式如:insert into tablename(字段1,字段2) select * from(select 字段1, 字段2,.... from dual) as b on duplicate key update字段1=b.字段1,....
例子:insert into trtb_dim_top_cats(cid,parent_cid,name,is_parent,status,sort_order,lev)select * from (select cid, parent_cid, name, is_parent, status, sort_order, lev from dual) as b -
on duplicate key update
cid=b.cid, parent_cid=b.parent_cid, name=b.name, is_parent=b.is_parent, status=b.status, sort_order=b.sort_order,lev=b.lev
MySQL insert update语句
MySQL Insert...Update 用法
最新推荐文章于 2025-02-21 16:55:07 发布
本文介绍 MySQL 中 insert...update 语句的使用方法,该语句能自动判断数据库中是否存在与要插入记录相同的主键,如果存在则进行更新操作,否则执行插入操作。通过示例展示了具体的语法结构。
9579

被折叠的 条评论
为什么被折叠?



