AB

AB

  • NA
  • 16
  • 0

Comining multiple Queries (C#, Microsoft Access, SQL)

Apr 9 2006 1:08 AM

Hello. Here's where I am stuck: I have multiple queries, each returning a list of ID's. I want to combine these multiple queries (Query1 thru Query4) in a bigger query (QueryFinal). For example:

QueryFinal
SELECT People.ID, People.Phone FROM People WHERE People.ID can be found in (Query1 Intersection Query2 Intersection Query3 Intersection Query4);

Query1
SELECT Customers.ID, FROM Customers WHERE Customers.Age > 45;

Query2
SELECT Loans.ID, FROM Loans WHERE Loans.Amount > 45000;

Query3
SELECT Cars.ID, FROM Cars WHERE Cars.Number > 2;

Query4
SELECT Family.ID, FROM Family WHERE Family.Children > 1;

Can it be done? If so, how?

This has to be with an Access database and the queries have to be multiple. This, with good reason: (1)Each table--People, Customers, Loans, Cars, Family--has almost 175 fields, (2)Every one of the queries Query1 thru Query4 has reached the limit of 99 "AND's" that are allowed by Access for the WHERE clause.

In Access itself, one can treat Query1 thru Query4 like tables and, therefore use an INNER JOIN to get the list of ID's common to all. But I am doing this in a C# Windows Form application and querying an Access Database.

All and any input will be appreciated. Thanks.


Answers (1)