I have a table that is the main table and then I have a two table(a
,b
) that have a foreign key of the main table. How can i retrieve by the a table
and b table
example:
table header is main id=1
then on the table a
got inserted one
, two than table b
got inserted one
, two
I want to display it by the row is one-one
then two-two
but right now i got an issue by displaying one-one
, one-two
, two-one
, two-two
my friend said that i must use hashmap the code below make me loop for unnecessary value
//this my code
ArrayList<Main>listMain = mainDAO.getlAllMain(Connection con);
for(Main listMain : listMain) {
ArrayList<A> listA = aDAO.getallbyMainId(Connection con, int main);
for(A listA : listA) {
ArrayList<B> listB = bDAO.getallbyMainId(Connection con, int main);
for(B listB : listB) {
Main main = new Main();
main.setMainName(listMain.getName());
a.set(listA.getName);
b.set(listB.getName);
}
}
}