Update Problem

  • I'm trying to do an up date but I can't get my head around it...

    Update [myTable]

    Set RevID = (Select otherTable.RevID from otherTable where Doc=otherTable.Doc and Rev=otherTable.Rev)

    Where Doc is not Null

    I need it to look at the 2 rows as if they were one though...

    Select otherTable.RevID from [otherTable] where [Doc+Rev] = [otherTable.Doc + otherTable.Rev]

    There are multiples of doc and rev but no multiples of the 2 combined...

    Is this possible?

  • The AND operator does what you want. By doing doc = doc AND rev = rev you are saying give me only records where BOTH doc and rev match. I typically write these types of statement like this:

    Update MyTable

    Set RevID = O.RevID

    From

    OtherTable O

    Where

    O.doc = MyTable.Doc And

    O.rev = MyTable.Rev

  • Thanks that worked a treat I was missing the "from other table" in my query...

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

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