Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 179
  • Last Modified:

sql query from 2 database files

i want to make sql query depending on 3 tables in 3 different files let us say that Table1 located in file1.mdb and Table2 located in file2.mdb and Table3 located in file3.mdb

when i tried to use a statment like this :
select Table1.Code , Table2.Ammount , Table3.Name From Table1 , Table2 , Table3 where Table1.Code = Table2.Code and Table1.Code = Table3.Code

i got error , anyone can help , Thanx
0
ashraf_t
Asked:
ashraf_t
  • 3
  • 2
  • 2
1 Solution
 
rquagliaCommented:
Hello!
A simple solution with Access:

You can make a new database, in which you LINK the three tables you need.
To link a table:
Database - New - link table (not import!)

Then you create a query with the Query wizard, defining every details about relationship between tables.

About the error in your query: maybe type of unique identifier are not the same ?

Hope this helps!
Roby


0
 
ashraf_tAuthor Commented:
sorry but i want more information , for example how to like the Table2 in file2.mdb with file1.mdb , Thanx
0
 
HilapdatusCommented:
Rquaglia's suggestion is the correct way to go.  Select one of the MDB files to be the "master", we'll use file1.mdb for example.  Open file1.mdb and create links for Table2 from file2.mdb and Table3.mdb.  File1.mdb will contain Table1 and references to Table2 and Table3.  From File1.mdb you will be able to execute your query.

If you need further explanation or help with the mouse-clicks to create the links, use Access' online help and search for "Linked Tables."
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
rquagliaCommented:
Hello ashraf_t!

To link differents tables in one DB try this (it's simpler doing it than explaining it!)



- Create a new database
now you have to add table:instead of design each table, you can import a table from other database. In Access97 (but it's quite the same in next Access editions) you have to press "New button", then "Link Table" (not "Import"),
then you choose the database (I.E. file2.mdb) where are the table you need,
then you choose the table (i.e. Table2) you need,
then press OK.

note: I don't have English edition (Italian one!), so command buttons may differ slightly, sorry!

Repeat this for every table you need to add.

Now you have a database with three different tables, that you can use inside a query. In the query, you need to define relation between tables, I.E. drag table2.code on table1.code and drag table 3.code on table1.code.

I hope this helps!
Roby

0
 
ashraf_tAuthor Commented:
oh both of you talking about linking tables inside the access application , sorry i want to make it inside th visualbasic , what statement i must write !!
0
 
HilapdatusCommented:
Ooh, ick... :(

I believe you'll have to execute three seperate queries, one for each table, and merge the result sets in code.

If you could create the linked tables in Access you would save yourself a lot of trouble.
0
 
rquagliaCommented:
... :-(
I agree with Hilapdatus, the better way is to link tables with Access!

Just an hint:
In VB6, use ADO through DataEnvironment (in View Environment under tools menu), and patch your MDAC with latest Service Pack from: http://www.microsoft.com/data/


0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now