Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Import data from two tables

Hi guys. I have the following tables in an Access database:

Customer

CustomerID

Name

Active?

123

Bob smith

Yes

444

John Jones

Yes

990

Ed Johnson

No

087

Paul Crisp

Yes

Address

CustomerID

Address

123

1 Shakespeare Road, Bedford.

444

5 Dudley Street, Bedford

990

9 Holly View, Sowerby Bridge

087

18 Church Lane, Ravensden

I would like to import only customers who are active. The problem with this is that if I tell the code to import only active from the customer table, it still imports the inactive information (customer 990) from the address table. Can anyone suggest anything?

My basic code is as follows:


ODBC CONNECT32 TO [MS Access Database;DBQ=C:\Users\u22471\Desktop\QV\New Microsoft Access Database.accdb];
SQL Select *

FROM [Customer];
ODBC CONNECT32 TO [MS Access Database;DBQ=C:\Users\u22471\Desktop\QV\New Microsoft Access Database.accdb];
SQL Select *

FROM [Address];

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

ODBC CONNECT32 TO [MS Access Database;DBQ=C:\Users\u22471\Desktop\QV\New Microsoft Access Database.accdb];
SQL Select *

FROM [Customer];
ODBC CONNECT32 TO [MS Access Database;DBQ=C:\Users\u22471\Desktop\QV\New Microsoft Access Database.accdb];

load *

where exists ( CustomerID ) ;

SQL Select *

FROM [Address];

View solution in original post

9 Replies
Anonymous
Not applicable
Author

ODBC CONNECT32 TO [MS Access Database;DBQ=C:\Users\u22471\Desktop\QV\New Microsoft Access Database.accdb];
SQL Select *

FROM [Customer];
ODBC CONNECT32 TO [MS Access Database;DBQ=C:\Users\u22471\Desktop\QV\New Microsoft Access Database.accdb];

load *

where exists ( CustomerID ) ;

SQL Select *

FROM [Address];

salto
Specialist II
Specialist II

Hi,

     Isn't it possible to add a where clause similar to:

         Active='Yes'

     And check the result?

Anonymous
Not applicable
Author

When i try this i get

SQL##f - SqlState: 07001, ErrorCode: 4294964286, ErrorMsg: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
SQL Select *

FROM [Customer]
Where [Active] = 'Yes'

Not applicable
Author

Hi,

Here both ODBC connections are same so no need to write connection string two times

ODBC CONNECT32 TO [MS Access Database;DBQ=C:\Users\u22471\Desktop\QV\New Microsoft Access Database.accdb];
Customers:

SQL Select *

FROM [Customer] where Active<>'No';

inner join(Customers)

Address:
SQL Select *
FROM [Address];

Anonymous
Not applicable
Author

Use :

where condition for Active column.

where Active ='Yes'

salto
Specialist II
Specialist II

Maybe:

SQL Select *

FROM [Customer]
Where [Active?] <> 'No'

Anonymous
Not applicable
Author

When i run this code i get

SQL##f - SqlState: 07001, ErrorCode: 4294964286, ErrorMsg: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
Customers:

SQL Select *

FROM [Customer] where Active<>'No'

salto
Specialist II
Specialist II

Is the field name correct [Active?]

Anonymous
Not applicable
Author


Sorry, i changed it to [Active] because i was worried the question mark was causing the issue which it wasnt