Importing CSV files into tables and Updating

naveen327

New Member
Joined
Jul 17, 2007
Messages
13
Hi I have imported two different CSV files (A.csv and B.csv) into two different tables (tbl_A and tbl_B) respectively using a VBA Import function.

My problem comes when I am trying to update a col_product (which is empty) in tbl_A with data from col_product in tbl_B on a inner join between column concat in tbl_A and col_concat in tbl_B.

My update query looks like this
UPDATE tbl_A SET tbl_A.Product = (SELECT tbl_B.Product
FROM tbl_B INNER JOIN tbl_A ON tbl_A.Concat=tbl_B.Concat);

The select subquery within the update returns 488 rows with the products but when I run the update query it shows 488 rows which are blank?

Note: Should I be telling the update query exactly which rows to update on in tbl_A?

Any help would be much appreciated.
Thanks, Naveen
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

wongm003

Board Regular
Joined
Aug 8, 2005
Messages
237
Hi Naveen,

It sounds like you want to update the Product field in tbl_A with the value in the Product field in tbl_B where the concat fields from both fields are equal... if so, you would use:

Code:
UPDATE tbl_A INNER JOIN tbl_B ON [tbl_A].Concat=[tbl_B].Concat 
SET tbl_A.Product = [tbl_B]!Product;

hope this helps.
 

Watch MrExcel Video

Forum statistics

Threads
1,130,119
Messages
5,640,218
Members
417,131
Latest member
Seanr19871

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top