Updating a column in one table through a column in another table
Try this one instead:
UPDATE ASET A.name = (SELECT B.name FROM B WHERE B.id = A.id AND B.name IS NOT NULL)WHERE a.name IS NULL;
Since you're using Oracle, here's the reference for IS NOT NULL.
Here's the SQL Fiddle so that you can play with it: http://sqlfiddle.com/#!4/a5ad0/3
I'm not sure from the above conversation whether you made any changes beyond indexing your data, but you should include a WHERE EXISTS
clause as mentioned. The complete query should look like this:
UPDATE A SET A.name = ( SELECT B.name FROM B WHERE B.id = A.id ) WHERE EXISTS ( SELECT 1 FROM B WHERE B.id = A.id )
The WHERE EXISTS
clause in your original query won't do much of anything except check to see if there is at least one non-NULL value of name
in B
.