1
How could I make the comparison with the EAN of another product without comparing it to the same product... in sql?
CREATE TABLE `produto`(
`idproduto` INT NOT NULL AUTO_INCREMENT,
`nome` VARCHAR(45) NOT NULL,
PRIMARY KEY (`idproduto`)
)
CREATE TABLE `eans` (
`cod_produto` INT NOT NULL,
`ean` VARCHAR(45) NOT NULL,
FOREIGN KEY (`cod_produto`)
REFERENCES `produto` (`idproduto`)
);
put in question the data model, structure of tables, because so it is difficult to help
– Ricardo Pontual
At first you could identify duplicate EANS using the clause
HAVING COUN(*) > 1
along with aGROUP BY EANS
.– anonimo