0
I performed a Query in the Mysql database, but I realized that I brought duplicate values. I didn’t understand where the problem might be in Query, follow the query.
select usuarios.nome as usuario,forma_pagamento.nome as forma, status.nome as statu, viagens.valor
as viagemValor, viagens.distancia as km, viagens.valor_extra as extra, viagens.data_criado as dtcriado,
entregadores.nome as entregadorNome
from viagens
inner join entregadores
on (viagens.entregadores_id= entregadores.entregadores_id)
inner join usuarios
on (viagens.usuarios_id= usuarios.usuarios_id)
inner join forma_pagamento
on (viagens.forma_pagamento_id=forma_pagamento.forma_pagamento_id)
inner join status
on (viagens.status_id=status.status_id)
where empresas_id= 11 and viagens.deleted = 0
and viagens.data_criado > '2018-03'
To answer, we would need to know how the data model is defined. Most likely it is not duplicated tuuuuudo, there must be information that is generating the Cartesian product. Most likely this
entregadores
. It is possible to have more than one courier for a trip?– Diego Rafael Souza