This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JDBC and the fly likes extracting data  from two table and populating them in a drop down box Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "extracting data  from two table and populating them in a drop down box" Watch "extracting data  from two table and populating them in a drop down box" New topic
Author

extracting data from two table and populating them in a drop down box

biswajit ray
Ranch Hand

Joined: Nov 30, 2005
Posts: 30
i have a table called category. In which i have two fields.namely categoryname and categoryid.
CATEGORYNAME CATEGORYID
____________ ________________
AllenSolly 1
Apparrel&Accessories 2
Kitchen 3

similarly i have table called SUBCATEGORY.In which i have 3 fields namely
SUBCATEGORYNAME PARENT_ID CHILDID
_______________ ___________ __________
men 1 11
women 1 12
child 1 13
accessories 2 21
giftvoucher 2 22
shopbybrand 2 23

all i want is that to combine the table and extracting the data and to populate in a dropdown box so that under allensolly men women and child will come.and under apparrelaccessories accessories giftvoucher shopbybrand will come.If possible plz give me the code.Plz help me
.
Sri Ram
Ranch Hand

Joined: Oct 03, 2005
Posts: 118
<HINT>
First try to write an SQL Query which fetches the data and group by the categoryName. Use Join to combine the table. I see that, ParentID is the reference to the CategoryId in the first table.

Now, use this query in java code to populate the dropdown.
[ February 15, 2006: Message edited by: Sri Ram ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: extracting data from two table and populating them in a drop down box