myql中如何将同一张表中某几条记录的某个字段复制到另外几条相对应的记录的字段中(批量拷贝字段)

我们要实现的效果就是将图中上半部分title字段赋值给图中下半部分stattype对一个记录的title字段

假设表明为sys_test表,需要是使用到join,语句如下:

update sys_test t1 join (select * from sys_test where  mark='Mark1') t2 on t1.stattype = t2.stattype set t1.title = t2.title where t1.mark='Mark1_copy1';
实现了批量拷贝字段


猜你喜欢

转载自blog.csdn.net/xiongmaodeguju/article/details/78879366