The purpose is to find a parent, given it's children. For example, say you have a marketing package (aka a "combo"), and want to match it based on the products in it. Example table/data:
create table marketing_package_product ( package_id int not null references marketing_package(id), product_id int not null references product(id), primary key (package_id, product_id) ); insert into marketing_package_product values (1,1), (1,2), (1,3), (2,1), (2,5);
Given products 1,2,3, I want to get marketing_package 1. But given products 1,2 only I do not want marketing_package 1.
Is there a name for this type of query, and what is the most efficient way to go about it?