BETWEEN with inner join does not work

1

I'm having a problem while doing a query using between with inner join, the query simply is not working, it returns the results as if the in between was not in the query. What am I doing wrong?

SELECT * FROM usuarios INNER JOIN matriculas ON (matriculas.idaluno = usuarios.id) WHERE matriculas.idcurso = :idcurso AND matriculas.data BETWEEN :dataini AND :datafim ORDER BY usuarios.nome ASC LIMIT 0,20

I'm putting everything right, including the dates I'm putting in the American standard Y-m-d which is what the operator between accepts. Without using inner join, the query works fine.

Remember that I'm using pdo.

    
asked by anonymous 04.10.2017 / 22:50

1 answer

0

Try to do with this query :

SELECT * FROM usuarios
INNER JOIN matriculas ON matriculas.idaluno = usuarios.id AND matriculas.data BETWEEN :dataini AND :datafim
WHERE matriculas.idcurso = :idcurso
ORDER BY usuarios.nome ASC
LIMIT 0,20
    
04.10.2017 / 22:57