File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Displaying records from multiple table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Displaying records from multiple table" Watch "Displaying records from multiple table" New topic
Author

Displaying records from multiple table

Bashar Ayyash
Ranch Hand

Joined: Jun 24, 2004
Posts: 44
Hi Guys,

I need your help to display records from multiple tables (tbl_users, tbl_dependants), I want to display user information in one row and user dependants in a column after ending user information, the two tables are related with (user_id). When the first user recordSet finishs displaying all user information + his dependants, it goes to the next line and print another user details,,, and so on.

I searched the entire forum for a help but I couldn't find.

Best Regards,
[ January 05, 2006: Message edited by: Bear Bibeault ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

What part are you having trouble with, the SQL, parsing the results?
What have you got so far?

There are a lot of ways to get from the database to the browser.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Bashar Ayyash
Ranch Hand

Joined: Jun 24, 2004
Posts: 44
I got so far, one row of user details + his dependants and a second row of another user details but without his dependants.

there is a little thing I must do but I couldn't figure it.

thanx for the help,
Matt Gatten
Greenhorn

Joined: Oct 29, 2005
Posts: 7
Your SQL statement could be written like this:



Hope that helps. They are called joins and you should read up on them.

You could also query all the names from the 1st table, loop through them and on each loop query for the dependents associated with that users name. That's not a very efficient way to do it, however.
[ January 05, 2006: Message edited by: Matt Gatten ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Displaying records from multiple table
 
Similar Threads
displaying records in jsp
Displaying records from multiple table
build a list page?
Help Regarding using Access Database in java
how to delete rows in the backend based on value displayed in the front end in struts2