android - Need help in fetch query -
i have table of cocktails contains id , name of cocktail (say id in range 1-16). these cocktails made combination of different ingredients. each cocktail made 3 ingredients or more.
so created table recipe contains details of each cocktail. illustration cocktail id 1 made ingredients' id - 1, 4, 14.
now suppose have ingredients 1-7 (any random 7 ingredients).ci need fetch cocktails created ingredients have.
i tried next query, returns me cocktails because each cocktail contains @ to the lowest degree 1 of ingredient
select * sb_receipe ingr_id in (1,2,3,4,5,6,7) grouping cock_id;
please help me prepare out issue.
thanks in advance
you want query returns cocktails utilize only ingredients have.
sql has no keyword only
; have express double negation: want cocktails no ingredient exists not in list:
select * cock not exists (select 1 sb_recipe cock_id = cock.id , ingr_id not in (1,2,3,4,5,6,7))
alternatively, not want cocktails utilize ingredient not in list:
select * cock id not in (select cock_id sb_recipe ingr_id not in (1,2,3,4,5,6,7))
android sqlite
No comments:
Post a Comment