0
I have this query in Mysql:
SELECT 
 usuarios.modalidade, 
 produtos.idproduto,
 produtos.nome,
 produtos.referencia,
 produtos.ean,
 produtos.valorvenda,
 produtos.quantidadeprodutos.minimo,
 tabeladepreco.desconto 
FROM produtos,tabeladepreco INNER JOIN usuarios ON
 tabeladepreco.modalidade = usuarios.modalidade 
WHERE produtos.nome like '%arroz%' AND 
 tabeladepreco.idproduto = produtos.idproduto AND 
 usuarios.modalidade = tabeladepreco.modalidade AND 
 produtos.ativo = 1
Where my idea is to bring all products with the name arroz, but if the form of the price list (tabeladepreco) is equal to the mode of the table usuários.
The search is correct, but,  the table usuarios has more than a thousand lines, and he repeats the products for each line.
I wonder if there’s any way he can do it just once, only I only have the mode to compare with the table usuarios.
It would be nice if you, instead of using
tabeladepreco.idproduto = produtos.idprodutoin AND, use in INNER JOIN: `FROM products INNER JOIN tableeladepreco ON tableeladepreco.idproduct = products.idproduct. Also remove AND redundancy from the mode.– Rogerson Nazário
I did it this way @Rogersonnazário:
SELECT produtos.idproduto,produtos.nome,produtos.referencia,produtos.ean,produtos.valorvenda,produtos.quantidade,produtos.minimo,tabeladepreco.desconto FROM produtos INNER JOIN tabeladepreco ON tabeladepreco.idproduto = produtos.idproduto WHERE produtos.nome like '%arroz%' AND produtos.ativo = 1But still repeats the result.– Fernando Trilha