mysql> SELECT mi.foodName, mi.price, mi.calories, mi.specialComments,
ind.ingredient FROM FoodTruck ft LEFT JOIN
Menu mi ON mi.truckID = ft.truckID LEFT JOIN Ingredients ind ON
ind.menuID = mi.menuID;
+----------------------+-------+----------+-----------------+-----------------+
| foodName | price | calories | specialComments | ingredient |
+----------------------+-------+----------+-----------------+-----------------+
| NULL | NULL | NULL | NULL | NULL |
| NULL | NULL | NULL | NULL | NULL |
| dustins dark rum | 3.5 | 285 | yummy | dark rum |
| dustins dark rum | 3.5 | 285 | yummy | ice |
| rad rachels rumchata | 3 | 375 | dairy free | rumchata |
| rad rachels rumchata | 3 | 375 | dairy free | almond milk |
| rad rachels rumchata | 3 | 375 | dairy free | chocolate syrup |
| rad rachels rumchata | 3 | 375 | dairy free | ice |
| NULL | NULL | NULL | NULL | NULL |
| NULL | NULL | NULL | NULL | NULL |
+----------------------+-------+----------+-----------------+-----------------+
10 rows in set (0.01 sec)
So, here is mySql query and the result, which via a PreparedStatement, is held in a ResultSet. How, exactly do I get the info out? I know I can have: while(rs.next()) { int x = resultSet.getInt(); String y = resultSet.getString();}
but is there a way to NOT repeat the foodName, price, calories and specialComments when dealing with the resultSet? I just need that for dustins dark rum
and rad rachels rumchata
and then every ingredient. Basically, as you can see from my query, this is joined from two different tables based on info from a third. So... it is kind of complicated. Not sure how to proceed or if my sql query can be fine tuned... Thank you!!