0
def checkMultipleIngredients():

    ingredients = []
    numberOfIngredients = int(input('Enter how many ingredients you would like to search for: ')) 
    for i in range(0, numberOfIngredients):
        x = input('Enter your ingredient: ')
        ingredients.append(x)      #makes array of elements inputted by the user
    print(ingredients)

    query = c.execute("SELECT DRDESC FROM Drinks WHERE DRDRID IN"
                  "(SELECT DTDRID FROM Detail WHERE INGID "
                  "=(SELECT INGID FROM Ingredients WHERE INDESC LIKE))",(ingredients,))

I am trying to end up with a list of drinks that have all of the ingredients in the array (user inputs the ingredients)

CL.
  • 173,858
  • 17
  • 217
  • 259
  • I don't think your sql syntax is even valid. You also pass an unused parameter, so what's the exact error? – OneCricketeer Apr 16 '17 at 21:43
  • Possible duplicate of [SQL Statement using Where clause with multiple values](http://stackoverflow.com/questions/10012695/sql-statement-using-where-clause-with-multiple-values) – pvg Apr 16 '17 at 21:43
  • Possible duplicate of [python list in sql query as parameter](http://stackoverflow.com/questions/283645/python-list-in-sql-query-as-parameter) – OneCricketeer Apr 16 '17 at 21:44
  • The SQL statement is the problem. I do not know how to query for all of the ingredients in the array and get out all of the drinks that have all of those ingredients. (Sorry for the confusion) – Nicco Narbutas Apr 16 '17 at 21:59

0 Answers0