I have experience in JOIN in SQL , but I'm getting a little to do in MySQL , can you help me? I already consulted here on the site, but I could not solve my problem. I thought JOIN and subselects to solve my problem.
I would like to relate and bring as a result the following information:
select nome from usuario
select nome from entregadores
select nome from status
I thought of this JOIN here, but it is in error.
select d.nome, c.nome, a.km, a.valor, a.valor_extra, a.data, b.nome from
viagens A
inner join b.entregadores
on (a.usuarios_id=d.usuarios_id)
inner join c.status
on (a.entregadores_id=b.entregadores_id)
inner join d.viagens
on (a.status_id=c.status_id)
The structure of my tables follows:
Travel table:
viagens_id
usuarios_id
entregadores_id
forma_pagamento_id
status_id
tipo_valor_id
endereco_origem
numero_origem
contato_origem
complemento_origem
ida_volta
data_horario
valor
valor_extra
observacoes
data_criado
data_modificado
user_modificou
distancia
ativo
deleted
Users table:
usuarios_id
grupo_id
empresas_id
nome
login
senha
email
telefone
codigo_seguranca
departamento
thumb
ramal
data_criado
data_modificado
ativo
deleted
Status table:
status_id
nome
ativo
deleted
padrao
Delivery table:
entregadores_id
veiculos_id
nome
cnh
telefone1
telefone2
placa
email
vencimento_cnh
foto_cnh
foto_doc
data_criado
data_modificado
ativo
deleted
Here is my last Query execution with the columns with the right name, it presented another error in PhpMyadmin "I had placed some columns with the wrong name, I arranged and I surrounded the query select status.name the statusName, trips.value
the travelValue, travel.distance, travel.value_extra,
deliverers.Name the delivererName
from trips
natural join handlers
natural join status
natural join users
PhpMyadmin has the error "# 1267 - Illegal combination of collations (latin1_swedish_ci, IMPLICIT) and (latin1_general_ci, IMPLICIT) for operation '='" "
select status.name the statusName, travel.value the travelValue, travel.distance, travel.value_extra, deliverers.Name the delivererName from trips natural join handlers natural join status natural join users