2010-09-15 48 views
0

更新我有2个表帮助的查询 - 从2个表

table1: num,X,Y 

table2: num,X,Y 

我需要在表1更新X和Y其中table1.num = table2.num

怎么办呢?

我需要在Oracle查询(我认为在SQL Server中,将工作太)

感谢的提前

回答

5

对于Oracle:

UPDATE table1 t1 
SET (x,Y) = (SELECT x, y from table2 
      WHERE t1.num = t2.num) 

为MSSQL:

UPDATE t1 
SET x = t2.x, 
    y = t2.y 
FROM table1 t1, table2 t2 
WHERE t1.num = t2.num 
+0

谢谢!!!!有用 !!!!! – Gold 2010-09-15 09:03:58