Question about SQL

  • Thread starter Thread starter Simon Harvey
  • Start date Start date
S

Simon Harvey

Hi everyone,

I was wondering if it is possible, to use SQL to return more than one table
at a time. I only know the basics of SQL and so I'm not sure if I'm just
asking a stupid question. But, I'm not proud! :-)

I'm using Ado.net and I'm wanting to load a DataSet object with several
independent tables. (For those who arent ADO.net programmers, a DataSet can
hold multiple tables and the relationships and contraints attached to
them. - Sort of like a mini-database as I understand it)

My question is - using SQL, will I have to execute several statements and
load the dataset manually, or is there some magic SQL command that I can use
to get more than one table back at once? I'm using an access database so I
can't use any stored procedures as I understand it. Don't know of that makes
any difference though.

Your advice as always is greatly appreciated.

Thanks

Simon
 
How about something like:

Select Table1.*, Table2.* From Table1 Inner Join Table2 On Table1.KeyField =
Table2.KeyField;

That will return the records from both tables with an equi-join on the
KeyField. The only way to return ALL the records from both tables with SQL
is with a Full Outer Join (not supported in Access) or a Cartesian Product.

You can also use sequential SQL statements in VBA code to return multiple
datasets
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Back
Top