| Author |
Accessing Multiple Tables
|
Chase Becicka
Greenhorn
Joined: Feb 16, 2004
Posts: 23
|
|
|
I just have a quick question with connecting to multiple tables, This is the first time I have attempted to code with a database cotaining multiple tables, is there anything special I need to do access the second table within my database or can I still just throw out the column name to connect to the resultset in that table
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26499
|
|
Chase, The first thing is to make sure you have a condition in your web clause to join the tables. Otherwise, you will get every combination of rows from both tables. If the column names are all distinct, you can still use the column name as is to get the result. If not, you can use a column number or an "as statement." For example:
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Bob Frapples
Ranch Hand
Joined: Mar 08, 2002
Posts: 32
|
|
you can access both tables the same way, and deal with the data in your app, this is no different than dealing with multiple Java objects, conceptually or you can use a join statement and have one single ResultSet, thus one object returned yet multiple tables are searched
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56554
|
|
"Brackish Water", Please take a look at the JavaRanch Naming Policy and adjust your display name to match it. In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious. Thanks! bear Forum Bartender
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Chase Becicka
Greenhorn
Joined: Feb 16, 2004
Posts: 23
|
|
Well my data tables do have one common column, its set up like this, my custNum is a column on both tables I have and the second table cannot exsist without a mathcing value in the first table so the CustNum links the two tables togeather and is the primary key for both tables
|
 |
 |
|
|
subject: Accessing Multiple Tables
|
|
|