Link to home
Start Free TrialLog in
Avatar of TBSupport
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.CustomerNumber and SOP30200.PRSTADCD = CUSTOMERS4SITE2.AddressCode)
OR
(SOP30200.CUSTNMBR = CUSTOMERS4SITE2.CustomerNumber and SOP30200.PRBTADCD = CUSTOMERS4SITE2.AddressCode)
where (CUSTOMERS4SITE2.CustomerNumber = SOP30200.CUSTNMBR and SOP30200.PRSTADCD = CUSTOMERS4SITE2.AddressCode)
OR
(CUSTOMERS4SITE2.CustomerNumber = SOP30200.CUSTNMBR and SOP30200.PRBTADCD = CUSTOMERS4SITE2.AddressCode)
ASKER CERTIFIED SOLUTION
Avatar of Lowfatspread
Lowfatspread
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial