有两张表,如何用SQL语句,将一张表中的某字段数据记录全部对应更新到另一张表中。将分为两种数据库SQL Server和Access做介绍。
表结构
功能
用表B的数据(mc列)更新表A的mc列
SQL Server
update A SET A.mc = b.mc FROM A ,B WHERE A.bmbh = B.bmbh and A.xmbh = B.xmbh;
Access
update A, B set A.mc = B.mc where A.bmbh = B.bmbh and A.xmbh = B.xmbh;
或
update A INNER JOIN B ON A.bmbh = B.bmbh AND A.xmbh = B.xmbh SET A.mc = B.mc;
声明:如需转载,请注明来源于www.webym.net并保留原文链接:http://www.webym.net/jiaocheng/733.html