Based upon what you posted this seems more an SQL question than a java specific question. To select across tables, you can use primary and foreign keys along with the JOIN keyword. As is, the tables look a bit confusing to achieve what you wish to achieve easily without knowing more about the database organization. You can try to organize it post-query using some arrays and such. Without any more information and code that's about all one can recommend.