I have two tables which are exactly alike. What I want to do is copy an entire column(DESCRIPTION)from one table(ebooks2) and put that information into the other table's(ebooks) description column where the Book # (BOOK) matches up. Is there a way to go about doing this?
The table you want to copy the description field into - does it already have the book # field filled in. If that is the case then use the update statement. If no data exists in the destination table then use insert into statement. So for an update you would do the following:
set test2.testy = (select test1.testy from test1 where test1.testyid = test2.testyid)
I believe this is what you are attempting to accomplish - update a second table that already has a key field populated and add additional information from the initial table to this table.
FYI - your insert statement needs to have the table first and then the field name so ebooks2.book not book.ebooks. Look at the following web site for future guidance in this area:
I still get errors when trying to execute that statement. Just in case i didn't give enough information to start with here is the situation. I have two tables. Both have the exact same fields as far as the key numbers and such. There is information in both tables some of which are different, such as description and things that haven't been updated in the one table. All the descriptions from the updated table got deleted about a month ago so some of them have the value N/A in them while others that have been recently added have an actual description. I want to take the descriptions from the old table where the book id matches the new table and put that old description in the new table's description spot.
Originally posted by rnealejr update updatedtable
set updatedtable.description =
where othertable.bookid = updatedtable.bookid)
If I tried this, I would get a "you have an error in your SQL syntax near 'select.....at line 1'". It hates having that open paren after the equals sign, absolutely hates and refuses to deal with it. So what do you do when this fails miserably? I'm trying to accomplish the same thing and having the worst luck.