复制字段到另一个表! A表(tid pk,tcontent),B表(tid pk,tcontent),将B表中的tcontent复制到A表中的tcontent中,A表的tid与B表的tid一样。语句应该如何实现呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 update b inner join a on b.tid=a.tidset b.tcontent=a.tcontent 方向反了。(将B表中的tcontent复制到A表中的tcontent中) update a inner join b on b.tid=a.tidset a.tcontent=b.tcontent 如果考虑B中有而A中没有的,并且 TID字段是唯一键的话可以。insert into Aselect * from bON DUPLICATE KEY UPDATEtcontent=values(tcontent) update a inner join b on b.tid=a.tid set a.tcontent=b.tcontentorupdate a,b set a.tcontent=b.tcontent where b.tid=a.tid update A,B set A.tcontent=b.tcontentwhere A.tid=B.tid 我写了一个,update a set a.tcontent = ( select b.tcontent from b where a.tid = b.tid ),感觉不是很好。呵呵,谢谢大家了。 数据库表是只读属性的 order by 中使用索引的问题 建表主键选择求解 关于两表查询取不重复的记录. 存储过程执行报 can't return a result set in the given context 如何在查询中依据变量比较显示新值,别名不能用 select into 自定义变量赋值问题 mysql.ini里面怎么设置Slow Query Log 寻求mysql数据同步方案 这是MySQL的BUG还是必然? mysql front 不能连接到 mysql 是怎么回事呢? 请大家帮忙看看,使用mysql connector/c++ 往数据库中插入blob字段出1210错
set b.tcontent=a.tcontent
set a.tcontent=b.tcontent
insert into A
select * from b
ON DUPLICATE KEY UPDATE
tcontent=values(tcontent)
or
update a,b set a.tcontent=b.tcontent where b.tid=a.tid
set A.tcontent=b.tcontent
where A.tid=B.tid