有两个表。
Table1:starttime,phone,duration,empid
Table2:starttime,phone,empid没有其它字段,也不能加其它主键。两个表通过starttimet和phone两个字段关联,即两个表中相对应的记录这两个字段是一样的。Table1中的empid有误,需要用Table2中的empid来更新Table1中的empid字段。
用Update语句怎么写?谢谢。
Table1:starttime,phone,duration,empid
Table2:starttime,phone,empid没有其它字段,也不能加其它主键。两个表通过starttimet和phone两个字段关联,即两个表中相对应的记录这两个字段是一样的。Table1中的empid有误,需要用Table2中的empid来更新Table1中的empid字段。
用Update语句怎么写?谢谢。
FROM table1 as t1, table2 as t2
WHERE t1.[phone] = t2.[phone]
AND t1.[starttime]=t2.[starttime]
两个表中的记录都是一对一的。
Table1:
2007/1/31 12345 10 1001
2007/1/30 12345 10 1002
2007/1/29 23456 10 1005Table2:
2007/1/31 12345 2
2007/1/30 12345 2
2007/1/29 23456 2
其它的类型是什么?我改一下类型再测你说的“操作符丢失”是语法错误,和数据的条目没有关系.
FROM table1 t1, table2 t2
WHERE t1.[phone] = t2.[phone]
AND t1.[starttime]=t2.[starttime]
where table1.startime=table2.starttime and table1.phone=table2.phone)
where table1.starttime=table2.starttime and table1.phone=table2.phone)
(select A.empid from table1 A,table2 B
where A.starttime=B.starttime and A.phone=B.phone)
(select A.empid from table1 A
inner join table2 B
ON A.starttime=B.starttime
and A.phone=B.phone)
楼上的报错:操作必须使用一个可更新的查询。
FROM table1 t1, table2 t2
WHERE t1.[phone] = t2.[phone]
AND t1.[starttime]=t2.[starttime]
update是不支持from子句的。
WHERE t1.[phone] = t2.[phone]
AND t1.[starttime]=t2.[starttime]