Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update query

Status
Not open for further replies.

samotek

Technical User
May 9, 2005
197
BG
I want to write a function looking into a query :
SELECT Customers.afid, orders1.customerid
FROM Customers INNER JOIN orders1 ON Customers.Customerid = orders1.customerid;

With the following condition :
If customers.afid = 3 , to update the order1.cusomerid to 124

Like that :
UPDATE Customers INNER JOIN orders1 ON Customers.Customerid = orders1.customerid SET orders1.customerid = 124
WHERE (((Customers.afid)=3));

Also, when customers.afid = 4, to update order1.customerid to 320
Etc etc

Can you help ?
 
Code:
UPDATE Customers 
INNER JOIN orders1 
ON Customers.Customerid = orders1.customerid 
SET orders1.customerid = iif(Customers.afid=3,124,iif(Customers.afid=4,32,orders1.customerid))
where Customers.afid in (3,4)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top