sql >> Base de Datos >  >> RDS >> Mysql

La consulta de MySQL devuelve filas no deseadas al buscar filas en función de combinaciones de etiquetas específicas

Sugiero usar unión simple para esto:

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