I have seen SQL syntax for an UPDATE...FROM before (I'm pretty sure) but can't seem to get it to work in Oracle. I have a Master table that I need to update with all of the matching information from a NewInfo table. Here's a sample of what i'm trying to do.
MASTER
id (number)
name (varchar)
company (varchar)
...and other fields.
NEWINFO
id (number)
name (varchar)
company(varchar)
I am looking for a statement like this:
UPDATE master
SET name = ni.name,
company = ni.company
FROM newinfo ni
WHERE id = ni.id
I need to update about 8000 rows and would like to do it all in a statement like the above. The SET ### = (SELECT..FROM..WHERE..) doesn't work with multiple records, so I'm looking for a way around this.
Actually I have about 4 more tables that I need to grab info from to update the records in this master table. The data is being imported from external sources first. That's why they're all in different tables.
The only other way I could think is to grab all IDs from one table and put them in an array, then loop through all of these IDs. I would think the above statement would be faster, but it doesn't seem to work. Can anyone tell me why it doesn't work, or the proper way to accomplish something like this?
Thanks a lot.
MASTER
id (number)
name (varchar)
company (varchar)
...and other fields.
NEWINFO
id (number)
name (varchar)
company(varchar)
I am looking for a statement like this:
UPDATE master
SET name = ni.name,
company = ni.company
FROM newinfo ni
WHERE id = ni.id
I need to update about 8000 rows and would like to do it all in a statement like the above. The SET ### = (SELECT..FROM..WHERE..) doesn't work with multiple records, so I'm looking for a way around this.
Actually I have about 4 more tables that I need to grab info from to update the records in this master table. The data is being imported from external sources first. That's why they're all in different tables.
The only other way I could think is to grab all IDs from one table and put them in an array, then loop through all of these IDs. I would think the above statement would be faster, but it doesn't seem to work. Can anyone tell me why it doesn't work, or the proper way to accomplish something like this?
Thanks a lot.