how to use select and update together

donjt81

Member
Joined
Jan 30, 2006
Messages
9
Programming Experience
Beginner
I have 2 tables with the following fields.

OrderInfo
PO Number
Status
CustomerInfo
Purchase Order Number
Customer Name
Customer Phone
Order Status

This is what I am trying to do:
get the Status for a the PO Numbers from the first table and update the Order Status field for those same PO Numbers in the second table.

This is how I am doing it currently:
I created a select query and saved it as ExistingPO. This is what ExistingPO looks like.
VB.NET:
SELECT OrderInfo.*
FROM CustomerInfo INNER JOIN OrderInfo ON CustomerInfo.[Purchase Order Number] = OrderInfo.[PO Number];
and then I created another query which makes use of this first select query. The second query looks like this
VB.NET:
UPDATE CustomerInfo INNER JOIN ExistingPO ON CustomerInfo.[Purchase Order Number] = ExistingPO.[PO Number] SET CustomerInfo.[Order Status] = ExistingPO.Status;
But I was wondering is there was a way to combine the first query and the second query into one query?
 
Correct me if I read this wrong, but it appears that you want to Update the second table (CustomerInfo). I do not see a need to include any reference to the first table in your update statement. Your Update statement should be a very simple single table update since you are not changing any OrderInfo fields.

Update statements and select statements are 2 very different animals and can not be combined.
 
Back
Top