Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Displaying records from multiple table

 
Bashar Ayyash
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bashar Ayyash
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic