aspose file tools*
The moose likes JDBC and the fly likes Looping through records while looping through record Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Looping through records while looping through record" Watch "Looping through records while looping through record" New topic
Author

Looping through records while looping through record

Leonardo Pjetri
Greenhorn

Joined: Dec 21, 2004
Posts: 29
I have 2 tables.
I look through the first table to find all the records that have the users email and display them, but part of the information is in the table 2. so I need to compare id (item) in table one with the one in table 2 so I can get the item�s description from table 2.

hope this makes sense




Thankyou
[ January 08, 2006: Message edited by: Leonardo Pjetri ]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18902
    
    8

I don't see why this is a JSP question. But anyway, why don't you just write one SQL statement that joins the two tables? And stick a where-clause in it while you're doing the change. It's much more effective (both in programming time and processing time) to have the database return only the data you need.

(Your current problem is that you are trying to use the "rs" ResultSet without setting it back to its start. But write the join-SQL instead of trying to do that.)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

"Leonardo",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. 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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

This is not a JSP question but a JDBC one.

You should get this code working in non-JSP java first. The I strongly receommend you not put the code directly within a JSP, but rather, keep it factored out in a class or bean that collects the data you want into an appropriate collection for passing to the JSP.

Moved to the JDBC forum.
Leonardo Pjetri
Greenhorn

Joined: Dec 21, 2004
Posts: 29
@ Paul i see what you mean thanks got it:



@ Bear done
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Looping through records while looping through record