views:

55

answers:

2

I have a table that has 5,000(table1) lines in it. Currently, 3,000 of them are filled up with data. The remaining values are currently null. In a separate table(table2), I have the remaining 2,000 rows of data. I am simply trying to take the values in table2 and put them in table1, but this statement isn't working:

Update table1
  Set field1 = (Select field1 
                  From table2 
                 Where table1.id = table2.id) 
Where Exists(Select field1 
               From table2 
              Where table1.id = table2.id)

It looks like this should be working, but I am getting an error from Base, the db program I am using that just says error Near " ": syntax error...any help?? Thanks!

+1  A: 

Try putting a space between Exists and (Select.

Chad Birch
+2  A: 

You could try doing it with a join. I'm used to doing it in T-SQL but I believe the syntax will be the same or pretty similar.

Update Table1
JOIN Table2 ON Table1.id = Table2.id
SET Table1.value = Table2.value
StevenGilligan
Wouldn't you need to add something like "where table1.value is null"?
Stacey Richards
Wouldn't work in Oracle
OMG Ponies