Updating table based upon matching field in second table

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dan Jones

    Updating table based upon matching field in second table

    I have a database of books that was originally created as a flat file.
    Each record has a number of fields, including the authors name. I'm
    trying to convert the database to something a little more efficient.
    I've created a new table (called Authors) of unique authors names and
    assigned each one a unique ID. I've added a new field in the original
    table (called Books) for the author's ID. Now, I need to update the
    original table with the author ID from the Author's table.

    Something like this:

    UPDATE Books SET AuthorID = Authors.AuthorI D WHERE AuthorName =
    Authors.AuthorN ame

    This obviously doesn't work. Any assistance on how to forumulate this
    query (or, if I'm headed down the wrong path, the correct way to do this
    operation) greatly appreciated.




    --
    MySQL General Mailing List
    For list archives: http://lists.mysql.com/mysql
    To unsubscribe: http://lists.mysql.com/mysql?unsub=m...ie.nctu.edu.tw

Working...