Queries problem

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I have two queries as sql strings. How can I take the results of two queries
and use them in a third sql query?

Thanks

Regards
 
Do each of these queries return single values? Assign them to variables and
use them in the third sql query. Maybe some code would be helpful...post
your code so we can see what you are trying to do.
 
The queries return multiple values. I am currently storing them in
datatables as below;

objAdapter1 = New OleDbDataAdapter("SELECT id FROM ... ", m_objConnection)
objAdapter1.Fill(MyDataTable1)

objAdapter2 = New OleDbDataAdapter("SELECT id FROM ... ", m_objConnection)
objAdapter2.Fill(MyDataTable2)

Now I am wondering if I can use mydatatable1 & mydatatable2 in my next query
or do I need to follow another rout altogether.

Thanks

Regards
 
If you post some table details along with the required results, we can
probably help more.
 
All tables have an 'id' field and records are returned based on some
criteria on other fields of the tables. In the next step I want to take the
results of the two queries (given earlier) and subtract one from the other
based on field 'id'.

Thanks

Regards
 
Something like

select * from table1 where table1.id in (select id from table2 where
table2.somethingelse='Red' and table2.id not in (select id from table3))

This way, you can do all work on the server and return only the final data
that you require

Or am I still misunderstanding your requirement?
 
Back
Top