Help updating a table with info from another.

  • Hi im reletively new to SQL and would like to know if I can do this.

    I have a main table Table1 which has name and address and a Field called Flag then I also have another table Table2 which also has name and address. I need to check the names and Address against each other then if the name and address is matched in Table1 then i need to change the value in Flag to 1. I need to check to 3 fields for matching NAME, ADD1 and POSTCODE.

  • nofear_1k (1/9/2008)


    Hi im reletively new to SQL and would like to know if I can do this.

    I have a main table Table1 which has name and address and a Field called Flag then I also have another table Table2 which also has name and address. I need to check the names and Address against each other then if the name and address is matched in Table1 then i need to change the value in Flag to 1. I need to check to 3 fields for matching NAME, ADD1 and POSTCODE.

    You cold use a statement like:

    UPDATE Table1

    SET Table1.flag = 1

    FROM Table2

    WHERE Table1.name = Table2.name

    AND Table1.add1 = Table2.add2

    AND Table1.postcode = Table2.postcode

    This will update the Table1.=flag column, and will set its value to 1 for every matched name and address.

    Regards,

    Andras

    Regards,

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

  • Many thanks that worked perfectly.

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

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