图中为A表的内容,表A中tofile字段里将每条数据前面“/uploads/allimg/c140320”替换成“/image”,后面文件名保持不变,最后再更新到B表中tofile字段。
具体要怎么做?求详细过程或sql语句。
update tableb b
inner join tablea a on b.column=a.column
set b.tofile=replace(a.tofile,'/uploads/allimg/c140320','/image')
where a.ofile like '/uploads/allimg/c140320%';
参考自:
mysql多表更新(跨表更新) http://www.data.5helpyou.com/article252.html
UPDATE A a set a.tofile = replace(a.tofile,"uploads/allimg/c140320","/image");
update 表名 set tofile=replace(tofile,'/uploads/allimg/c140320','/image') where tofile like '/uploads/allimg/c140320%'
两表关联以后,加上所需条件,执行update语句,字段替换。