使用另一个表列更新一个表的列。 [英] Updating column of one table with another table column.

查看:77
本文介绍了使用另一个表列更新一个表的列。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试过这个查询,用一个第二个表的列更新一个表的列。

I have tried out this query for updating a column of one table with the values from a column of a second table.

UPDATE t1
SET address1 = t2.address1


UPDATE t1
SET address1 = t2.address1
FROM t1 
INNER JOIN t2 ON t1.name_id = t2.name_id
WHERE t1.account_no = '938'


This query is giving an error 
(Error 933: ORA-00933: SQL command not properly ended)

This error is being pointed to "From" or before it, saying that the error is occuring there. Have tried working on the same without the join too but didnt help. Any suggestion on what is wrong will is greatly appreciated.

Thank You.

推荐答案

请使用此:

Please, use this:
UPDATE t1
SET t1.address1 = t2.address1
FROM TableName1 AS t1 
INNER JOIN TableName2 AS t2 ON t1.name_id = t2.name_id
WHERE t1.account_no = '938'





你看到了变化吗?


换句话说,上面的意思是:



Do you see changes?

In other words, above means:

UPDATE
    MainTable
SET
    MainTable.col1 = OtherTable.col1,
    MainTable.col2 = OtherTable.col2
FROM
    MainTable
INNER JOIN
    OtherTable
ON
    MainTable.id = OtherTable.id





资料来源: http://stackoverflow.com/questions/2334712 / update-from-select-using-sql-server [ ^ ]







Source: http://stackoverflow.com/questions/2334712/update-from-select-using-sql-server[^]


UPDATE PEOPLE a
SET a.SURNAME = (
select b.SURNAME
from PEOPLE b
where b.NI.NO = a.NI_NUMBER
)







来源:< a href =http://www.dba-oracle.com/ t_ora_00933_sql_command_ended.htm> ORA-00933:SQL命令未正确结束 [ ^ ]

[/ EDIT]




Source: ORA-00933: SQL command not properly ended[^]
[/EDIT]


这篇关于使用另一个表列更新一个表的列。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆