Update using a Select Query

  • Hi,

    I am trying to update a field in a parent table based on a cross table select query.

    See below the queries I am working with. The issue I am having is that the update query updating every row in the wce_contact table, whereas if I just run the Select part of it, I get 1100 results, which is the amount of records I want updated when I do the update query.

    Any ideas on why this is happening and how i can fix it would be great. Thanks for looking.

    SELECT Query

    SELECT *

    FROM Logix_Opportunity as o

    inner join wce_contact c on o.accountid = c.accountid

    where Extensions like 'Sales Logix - Import 031210%' AND o.createdate >= '20100901');

    UPDATE Query

    UPDATE wce_contact

    SET scw_temp = 'Sales Logix Live'

    WHERE EXISTS (

    SELECT *

    FROM Logix_Opportunity as o

    inner join wce_contact c on o.accountid = c.accountid

    where Extensions like 'Sales Logix - Import 031210%' AND o.createdate >= '20100901');

  • Something like this ?

    UPDATE c

    SET scw_temp = 'Sales Logix Live'

    from Logix_Opportunity as o

    inner join wce_contact c on o.accountid = c.accountid

    where Extensions like 'Sales Logix - Import 031210%' AND o.createdate >= '20100901'



    Clear Sky SQL
    My Blog[/url]

  • That worked great, thank you.

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

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