• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Looping through records while looping through record

 
Leonardo Pjetri
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21155
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64994
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64994
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@ Paul i see what you mean thanks got it:



@ Bear done
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic