-1
I have the following query above as per the image.
Why is she mixing the fields?
SELECT
celulasreunioes.idCelula,
celulas.nome,
celulas.idRede,
redes.nome,
celulas.idRegiao,
regioes.nome,
celulas.idArea,
areas.nome,
celulas.idSetor,
setores.nome,
celulasreunioes.data,
celulasreunioes.presentes,
celulasreunioes.visitas,
celulasreuniOes.criancas,
celulasreunioes.decisoes,
celulasreunioes.discipulados,
celulasreunioes.jejum,
celulasreunioes.evangelismo,
celulasreunioes.supervisao,
celulasreunioes.oferta
FROM celulasreunioes, pastores, redes, regioes, areas, setores, celulas
WHERE
celulas.idRede = redes.idRede AND
celulas.idRegiao = regioes.idRegiao AND
celulas.idArea = areas.idArea AND
celulas.idSetor = setores.idSetor AND
celulas.idPastor = pastores.idPastor AND
celulas.idPastor = 2 AND
data BETWEEN NOW() - INTERVAL 30 DAY AND NOW()
/*GROUP BY celulas.idCelula*/
ORDER BY celulas.idSetor
For example:
To Cell of 17 is the Cell 1 To Cell of 18 is the Cell 2
But the query
says that Cells 17 and 18 are the same time to 1 and 2
In case I cross the line
/*GROUP BY celulas.idCelula*/
Which is the goal, the return gets even worse because omit the outworking to the Cell 18 as shown below.
The expected return (with the other clauses of query) )is as in the figure below that has only the meeting table print:
Following the help of Rafael Dias, and how **NÃO**
there is how to post a new answer to help in the forum because they put the question as pending, I will put right here as was the query
final, but already compiled
SELECT
celulasreunioes.idCelula,
celulas.nome as nomeCelula,
pastores.idPastor,
membros.nome as nomePastor,
celulas.idRede,
redes.nome as nomeRede,
celulas.idRegiao,
regioes.nome as nomeRegiao,
celulas.idArea,
areas.nome as nomeArea,
celulas.idSetor,
setores.nome as nomeSetor,
celulasreunioes.data,
celulasreunioes.presentes,
celulasreunioes.visitas,
celulasreuniOes.criancas,
celulasreunioes.decisoes,
celulasreunioes.discipulados,
celulasreunioes.jejum,
celulasreunioes.evangelismo,
celulasreunioes.supervisao,
celulasreunioes.oferta
FROM
celulasreunioes,
pastores,
redes,
regioes,
areas,
setores,
celulas,
membros
WHERE
celulas.idRede = redes.idRede AND
celulas.idRegiao = regioes.idRegiao AND
celulas.idArea = areas.idArea AND
celulas.idSetor = setores.idSetor AND
celulas.idCelula = celulasreunioes.idCelula AND
celulas.idPastor = pastores.idPastor AND
pastores.idPastor = membros.idMembro AND
data BETWEEN NOW() - INTERVAL 7 DAY AND NOW()
ORDER BY
celulas.nome,
membros.nome,
redes.nome,
regioes.nome,
areas.nome,
setores.nome
And what are the data present in the table? What would be the expected result?
– Woss
added to the question!
– Carlos Rocha
also adds a cell select equal to 17 and 18. Just to make sure your table has not been duplicated.
– HudsonPH
I can not because there will be more than 300 cells, in this moment of development I only registered these 2. Or I did not understand your guidance.
– Carlos Rocha
select * form cellulasesWhere meetings idCellular = 17
– HudsonPH
So you’re saying that there’s only two records in the table? You can create a [mcve] using https://www.db-fiddle.com/?
– Woss
The query is running perfectly. If you want a result different than expected, please [Dit] the question and put a demonstration of the expected result and an explanation of why you think it should be different from the one presented. The way it is, you can’t know where the logic error is (the answer may be a solution, but only knowing for sure what the original intention is)
– Bacco