Desired Result: Find everyone who has purchased both gum and baskets.
Example: (However, just about every column is stored on different tables.)
Desired Result: Find everyone who has purchased both gum and baskets.
Example: (However, just about every column is stored on different tables.)
Desired Result: Find everyone who has purchased both gum and baskets.
This is a typical case of relational-division.
Assuming a UNIQUE (or PK) constraint on (name, purchase)
a query like this does the job:
SELECT name
FROM tbl t1
JOIN tbl t2 USING (name)
WHERE t1.purchase = 'Gum'
AND t2.purchase = 'Baskets';
See: