johnnyg123
asked on
Case with exists with innerjoin in update query
Here is some sample data from 2 tables I have
Table 1
MailCustomer
CustomerID
12345
56768
Table 2
CustomerOrder
CustomerID MailFlag
12345
66666
I am trying to write an update query that will :
update the Customer flag to 'T' on Customer Order table If the Customer Number exists in the Mail Customer table.
update the Customer flag to 'F' on Customer Order table If the Customer Number does not exist in the Mail Customer table.
Given data above table below should look like below after query
CustomerOrder
CustomerID MailFlag
12345 T
66666 F
Was thinking of using case with inner join but not sure how
Table 1
MailCustomer
CustomerID
12345
56768
Table 2
CustomerOrder
CustomerID MailFlag
12345
66666
I am trying to write an update query that will :
update the Customer flag to 'T' on Customer Order table If the Customer Number exists in the Mail Customer table.
update the Customer flag to 'F' on Customer Order table If the Customer Number does not exist in the Mail Customer table.
Given data above table below should look like below after query
CustomerOrder
CustomerID MailFlag
12345 T
66666 F
Was thinking of using case with inner join but not sure how
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
and of course make sure you have a index on customerorder.customerid to get the update done fast
ASKER
Great! Thanks!