Home » RDBMS Server » Server Administration » Update
Update [message #371549] Mon, 06 November 2000 10:46 Go to next message
Ronh
Messages: 1
Registered: November 2000
Junior Member
I'm trying to update 1 table with info from another table. The column to update must only be updated where value in another column is equal in both tables.
Re: Update [message #371555 is a reply to message #371549] Tue, 07 November 2000 04:14 Go to previous message
John R
Messages: 156
Registered: March 2000
Senior Member
I think the SQL you are looking for is either:

UPDATE table_1
SET column_1 = (SELECT nvl(max(table_2.column_1)
,table_1.column_1)
FROM table_2
WHERE table_2.column_2 = table_1.column_2)

Or you can use

UPDATE table_1
SET column_1 = (SELECT column_1
FROM table_2
WHERE table_2.column_2 = table_1.column_2)
WHERE EXISTS (SELECT 1
FROM table_2
WHERE table_2.column_2 = table_1.column_2

Hope this heplps
Previous Topic: Autoincrement Identity Field
Next Topic: UTL_FILE reading from file (Rec Lenght>1k)
Goto Forum:
  


Current Time: Fri May 03 16:58:23 CDT 2024