Hi all,

Lets say I have a table with two colums: 'orderid' and 'productid'.  This
table contains line items for purchases in a store where a purchase could
be 1 or more line items (1 or more rows).  A typical order may look like
this:

orderid | productid
12345   | 9876
12345   | 6789
12345   | 7698

Is there a simple way to query the table to pull orders which have 2 or
more products in common?  For example, if order 12345 has 5 line items and
order 12348 has 7 line items, I would like the query to return these two
orders if they have products 9876 and 6789 in common, and I would also
like it to return orders 23456, 65432 and 34567 where they have 8796, 6789
and 4456 in common.  I hope I'm explaining this well...I know what I'm
trying to accomplish in my head, but we all know that doesn't always
translate too well in an email.  :)  For the record, this is a MySQL
4.1.22 db.  TIA

--
John C. Nichel IV
System Administrator
KegWorks
http://www.kegworks.com
716.362.9212 x160
j...@kegworks.com

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql

Reply via email to