Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have tried out this query for updating a column of one table with the values from a column of a second table.
SQL
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.
Posted

1 solution

Please, use this:
SQL
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:
SQL
UPDATE
    MainTable
SET
    MainTable.col1 = OtherTable.col1,
    MainTable.col2 = OtherTable.col2
FROM
    MainTable
INNER JOIN
    OtherTable
ON
    MainTable.id = OtherTable.id


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

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



Source: ORA-00933: SQL command not properly ended[^]
[/EDIT]
 
Share this answer
 
v2
Comments
Anoop P V 24-Jul-13 1:32am    
I have tried that too :( ... This query is throwing the same error
(Error 933: ORA-00933: SQL command not properly ended).
Maciej Los 24-Jul-13 1:41am    
See my updated answer. next time, please, be more specific and provide more details about problem and database specification.
Anoop P V 9-Jan-14 0:11am    
Alright. Thank You :)
Maciej Los 9-Jan-14 1:51am    
Please, accept this answer as a solution (green button) - formally, to remove this question from unanswered collection.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900