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

Access SQL Query Error

Status
Not open for further replies.

new_to_sql

Technical User
Nov 3, 2021
3
US
Hi all,

Thanks in advance for your help. I have two queries that have a common field but the columns are not the same other than the common field. I need data from both queries if query A and query B common field "ID" are the same. Note query B has more data than query A. I want to pull in data from both queries if query A "ID" is found/matched in query B. I tried the below but I keep getting syntax error. I tried using query wizard and join "ID" field but access hangs and crashes or only shows me data from one of the queries

Select * FROM [Query A] INTERSECT [Query B]
Where[Query A].[ID] =[Query By].[ID];

Not sure what I am doing wrong, but if you can help guide me to right solution that would be greatly appreciated.

Thank you in advance for your help.
 
Select * FROM [Query A] INTERSECT [Query B]
Where[Query A].[ID] =[Query [highlight #FCE94F]By[/highlight]].[ID];

Can we assume that [tt]Query By[/tt] is a typing error, and you actually meant [tt]Query B[/tt]?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Mike,

Yes that is a typing error and is meant to be query B.
 
>I want to pull in data from both queries if query A "ID" is found/matched in query B.
An old fashioned way would be:

[pre]
Select A.*, B.*
From [Query A] A, [Query B] B
Where A.ID = B.ID[/pre]

And since you said: "access hangs and crashes", you may get better response in any of the Access forums.
This is an SQL Server forum.

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Thanks Andy - appreciate the help and will take it to Access Forum. Thank you again for your help
 
If the tables/data is on SQL server you should consider creating a view on SQL Server or use a pass-through query in MS Access.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top