Typically, with Core Data, you will design and use a data model that fits your needs. You should not think about it from the point of view of SQL - it does not even need to use SQL for storage - and you should not try to directly translate the SQL query into a query query using a predicate, etc.
However, it is sometimes useful to think in terms of SQL WHERE clauses when constructing predicates, but in fact the query selections come down to what you need to get, and how the collection should be filtered and / or sorted, etc.
Sample requests are limited to a single object, so I think you will need several sample requests to simulate your request.
What does your Core Data model look like? What are you trying to achieve? What have you tried so far?
UPDATE
It looks like your data model includes two objects: Drink and Ingredient with a many-to-many relationship between them:
Drink ↔ Ingredient
Note that there is no DrinkIngredient object in Core Data unless you explicitly create it (there is an additional table for many-to-many relationships, but it is distracted from you). Since you want the sum value associated with the rows in the additional table, I would recommend adding a DrinkIngredient object to Core Data:
Drink ↔> DrinkIngredient ↔ Ingredient
Note. DrinkIngredient has exactly one drink and one ingredient. Drinks can have many DrinkIngredients and Ingredients, which can be used by many DrinkIngredients.
It looks like you want to get a name and quantity for a list of ingredients for a specific drink. To do this, simply select the DrinkIngredient objects with the filter predicate as follows:
// assuming "aDrink" is a reference to a particular Drink object // and "drink" is the relationship from DrinkIngredient to Drink fetchRequest.predicate = [NSPredicate predicateWithFormat:@"drink == %@",aDrink]; // if the fetch request result array is named "ingredientList" // and the relationship from DrinkIngredient to Ingredient is "ingredient" for (DrinkIngredient *di in ingredientList) { NSString *ingredientName = di.ingredient.name; NSUInteger amount = di.amount.integerValue; // use "ingredientName" and "amount" here }
Since you are using Core Data, not SQL, you are doing something different. For example, if you want to display a list of ingredients with a name and amount for all drinks, you simply get all Drink objects (without a filter predicate), and you get access to the ingredients through a relationship from Drink to DrinkIngredient.
Again, you should think about what you are trying to accomplish, as well as correctly design and use your data model. You should not think about SQL or queries.