else{ //to get recipes that have at least the listed ingredients, taking quantity into consideration System.out.println("HI"); String temp = "LOL"; ArrayList IDListBase = new ArrayList(); String recNameQuery="SELECT recipe_id, recipe_name FROM recipe WHERE NOT EXISTS( SELECT * FROM ingredient_recipe WHERE NOT"; for (int j=0; j DirectionsList = new ArrayList(); while(rs.next()) { temp = rs.getString("recipe_ID"); DirectionsList.add(temp); } for (String q : DirectionsList){ System.out.println(q); } System.out.println("HI"); /* recNameQuery="SELECT recipe_id, recipe_name FROM recipe WHERE directions='% ? %'"; st.setString(1, keyword); rs=st.executeQuery(); */ //to search by ethnicity String ethnicity= ethnicityBox.getSelectedItem().toString().toLowerCase(); System.out.println(ethnicity); recNameQuery="SELECT recipe_id, recipe_name FROM recipe WHERE LOWER(ethnicity) = ? "; st.setString(1,ethnicity); rs=st.executeQuery(); System.out.println("HI"); ArrayList EthnicityList = new ArrayList(); while(rs.next()) { temp = rs.getString("recipe_ID"); EthnicityList.add(temp); } for (String v : EthnicityList){ System.out.println(v); } ArrayList Result = new ArrayList(); for(String s : IDListBase){ if(EthnicityList.size()==0){ if(DirectionsList.contains(s))Result.add(s); } else if (DirectionsList.size()==0){ Result.add(s); } else if(EthnicityList.contains(s)&&DirectionsList.contains(s)){ Result.add(s); } } System.out.println("HI"); for (String a : Result){ System.out.println(a); } //to get recipes that have only the listed ingredients, taking quantity into consideration } // end else (!anyParam)