• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

display data from a joined table

 
kessy cruz
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1604
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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'
 
kessy cruz
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks you, both I'm still lost. What should I put in the last part (... WHERE categories.ID =?).
 
Surendra Kumar
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 236
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much. This is my problem. Using php and I'm new to it. I will give it a try
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic