Update的有关问题(解决马上结帖)

Update的问题(解决马上结帖)
有两个表。
Table1:starttime,phone,duration,empid
Table2:starttime,phone,empid

没有其它字段,也不能加其它主键。两个表通过starttimet和phone两个字段关联,即两个表中相对应的记录这两个字段是一样的。Table1中的empid有误,需要用Table2中的empid来更新Table1中的empid字段。
用Update语句怎么写?谢谢。

------解决方案--------------------


UPDATE table1 SET table1.[empid] = t2.[empid]
FROM table1 as t1, table2 as t2
WHERE t1.[phone] = t2.[phone]
AND t1.[starttime]=t2.[starttime]
------解决方案--------------------
楼主,我按你在贴中的说明建表试过了,可用,再说,我对这样的语句还是有信心的.
------解决方案--------------------
UPDATE table1 SET empid =
(select A.empid from table1 A,table2 B
where A.starttime=B.starttime and A.phone=B.phone)
------解决方案--------------------
UPDATE table1 t1 ,table2 t2 SET t1.[empid] = t2.[empid]
WHERE t1.[phone] = t2.[phone]
AND t1.[starttime]=t2.[starttime]