wood burning stoves*
The moose likes JDBC and the fly likes display data from a joined table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "display data from a joined table" Watch "display data from a joined table" New topic
Author

display data from a joined table

kessy cruz
Greenhorn

Joined: Dec 13, 2010
Posts: 29
Good day, please I have 3 tables Categories(ID,name) Preachers(ID,name) and PreachCategory(categoriesID, preachersID).
Please, I want to display preachers for a particular category. So that when a user click on the d particular category, it display d list of preachers. Thanks
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1449
    
    6

select Preachers.name from Preachers inner join PreachCategory on Preachers.ID=PreachCategory.preachersID
inner join Categories on Categories.ID=PreachCategory.categoriesID where Categories.ID='id given by user'


Swastik
kessy cruz
Greenhorn

Joined: Dec 13, 2010
Posts: 29
Thanks you, both I'm still lost. What should I put in the last part (... WHERE categories.ID =?).
Surendra Kumar
Ranch Hand

Joined: Jul 04, 2006
Posts: 235
In your original post you said users click on particular category id, and that is what you need to use in your query.
kessy cruz
Greenhorn

Joined: Dec 13, 2010
Posts: 29
Sorry, there is a list of categories in d home page. How do I pass any of those category into d query. so when user click on any of this category, it displays d preachers for that category
Surendra Kumar
Ranch Hand

Joined: Jul 04, 2006
Posts: 235
You can send the category id as a parameter in the query string to your servlet, and your servet can access it using request.getParameter("categoryId"), and from the servlet you pass the value to your DAO (Data Access Object).

So your URL looks like "http://localhost:8080/YourContextRoot/YourServletName?categoryId=5".
kessy cruz
Greenhorn

Joined: Dec 13, 2010
Posts: 29
Thank you very much. This is my problem. Using php and I'm new to it. I will give it a try
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: display data from a joined table
 
Similar Threads
Problem with sessionScoped
Editing mySQL data that is displayed in a html table
SQL Results
parent/child structure display using jsp
Convert one Object to another Object