Update From Select

  • Hi, help I need my brain cells refreshing - been a long day.

    I need to update a field in a table base on records in another table

    Something like:

    UPDATE tableA Set ItemName = SELECT ItemName From TableB WHERE TableA.ID = TableB.ID

    But Query Analyser dont like that.

    Where Am I going wrong?

    Andy

  • Try this:

    UPDATE tableA

    Set tableA.ItemName = TableB.ItemName

    From tableA

    inner join TableB ON TableA.ID = TableB.ID

  • Yep, thats it. Many thanks JeffB

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply