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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to query data from two different databases 1

Status
Not open for further replies.

glgcag

MIS
Apr 25, 2001
160
US
I have used the "IN 'Z:\Databases\MyDatabase.mdb'" query syntax to extract data from another database into the db I have open. But I've never combined data from an external database with data in the open database in one query. How might I do this? Here is the query I've created:

UPDATE tAGProjects INNER JOIN tPTProjects ON tAGProjects.AGProjectKey = tPTProjects.AGProjectKey SET tPTProjects.ProjectTitle = [tAGProjects].[ProjectTitle]
WHERE Exists (SELECT * FROM tPTProjects WHERE tAGProjects.AGProjectKey = tPTProjects.AGProjectKey) AND tAGProjects.ProjectTitle <>[tPTProjects].[ProjectTitle];

tPTProjects is in my open database but tAGProjects is in an external database. Where do I put the "IN 'Z:\Databases\MyDatabase.mdb'" part?

Thanks for the help!
 
You need a different syntax for this
Code:
UPDATE [red][;Database=Z:\Databases\MyDatabase.mdb].[/red]tAGProjects INNER JOIN tPTProjects ON tAGProjects.AGProjectKey = tPTProjects.AGProjectKey SET tPTProjects.ProjectTitle = [tAGProjects].[ProjectTitle]
WHERE Exists (SELECT * FROM tPTProjects WHERE tAGProjects.AGProjectKey = tPTProjects.AGProjectKey) AND tAGProjects.ProjectTitle <>[tPTProjects].[ProjectTitle];
 
Golom,

Thank you for the help, it worked perfectly! I also double checked the updates prior to making them and after to confirm everything was good. I used your help on the "check" query as well:

Code:
SELECT tAGProjects.AGProjectKey, tAGProjects.ProjectTitle, tPTProjects.ProjectTitle
FROM [COLOR=red][;Database=Z:\Database\MyDatabase.mdb].[/color]tAGProjects INNER JOIN tPTProjects ON tAGProjects.AGProjectKey = tPTProjects.AGProjectKey
WHERE tAGProjects.ProjectTitle <> tPTProjects.ProjectTitle;

I'm going to use this a lot now, thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top