TBSupport
asked on
How to Update a Table Using “OR” Joins
Hello:
In tables called IV00102 and RM00102, for a certain set of customers with Address IDs, I changed the Site ID (i.e. location) to 2. Now, I need to--in GP's Sales Order Processing module's history--change the Site ID for the same customers and Address IDs to 2. That set of customers is in a table called "CUSTOMERS4SITE2".
The problem that I'm having with the T-SQL query update statement is that--for the SOP30200 table--I don't know if the Address IDs in CUSTOMERS4SITE2 are a "ship to ID" (SOP30200.PRSTADCD) or "bill to" ID (SOP30200.PRBTADCD).
Below is the update statement that I have. Will this work?
TBSupport
UPDATE SOP30200 SET SOP30200.LOCNCODE = '2'
from SOP30200
INNER JOIN CUSTOMERS4SITE2 ON (SOP30200.CUSTNMBR = CUSTOMERS4SITE2.CustomerNu mber and SOP30200.PRSTADCD = CUSTOMERS4SITE2.AddressCod e)
OR
(SOP30200.CUSTNMBR = CUSTOMERS4SITE2.CustomerNu mber and SOP30200.PRBTADCD = CUSTOMERS4SITE2.AddressCod e)
where (CUSTOMERS4SITE2.CustomerN umber = SOP30200.CUSTNMBR and SOP30200.PRSTADCD = CUSTOMERS4SITE2.AddressCod e)
OR
(CUSTOMERS4SITE2.CustomerN umber = SOP30200.CUSTNMBR and SOP30200.PRBTADCD = CUSTOMERS4SITE2.AddressCod e)
In tables called IV00102 and RM00102, for a certain set of customers with Address IDs, I changed the Site ID (i.e. location) to 2. Now, I need to--in GP's Sales Order Processing module's history--change the Site ID for the same customers and Address IDs to 2. That set of customers is in a table called "CUSTOMERS4SITE2".
The problem that I'm having with the T-SQL query update statement is that--for the SOP30200 table--I don't know if the Address IDs in CUSTOMERS4SITE2 are a "ship to ID" (SOP30200.PRSTADCD) or "bill to" ID (SOP30200.PRBTADCD).
Below is the update statement that I have. Will this work?
TBSupport
UPDATE SOP30200 SET SOP30200.LOCNCODE = '2'
from SOP30200
INNER JOIN CUSTOMERS4SITE2 ON (SOP30200.CUSTNMBR = CUSTOMERS4SITE2.CustomerNu
OR
(SOP30200.CUSTNMBR = CUSTOMERS4SITE2.CustomerNu
where (CUSTOMERS4SITE2.CustomerN
OR
(CUSTOMERS4SITE2.CustomerN
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.