これには単純な結合を使用することをお勧めします:
SELECT DISTINCT a.lot, b.lot
FROM mytable a
INNER JOIN mytable b ON b.product = a.product AND NOT EXISTS (SELECT * FROM product WHERE tag NOT IN (a.tag, b.tag))
WHERE a.tag = 101 and b.tag = 102
これには単純な結合を使用することをお勧めします:
SELECT DISTINCT a.lot, b.lot
FROM mytable a
INNER JOIN mytable b ON b.product = a.product AND NOT EXISTS (SELECT * FROM product WHERE tag NOT IN (a.tag, b.tag))
WHERE a.tag = 101 and b.tag = 102