Next. Imagine that I have in the bank in the field of paid months the following launches: 2015-03, 2015-04, 2015-7, 2015-9. If we stipulated a period for example: from 2015-02 until today (2015-9). What months are missing, ie, which months have not yet been paid.
The query I'm submitting here brings in the months INSIDE of the period. But what I need is NOT months paid, but SIM PAYMENTS and IN of the period. That is, 2015-2, 2015-5, 2015-6, 2015-8.
SELECT pagamentos.idPagamentos, pagamentos.mesReferencia FROM pagamentos, planosclientes
WHERE
pagamentos.idPlanoClientes = planosclientes.idPlanosClientes AND
pagamentos.idPlanoClientes = 8 AND
pagamentos.mesReferencia BETWEEN DATE_FORMAT(planosclientes.dataInstalacao, '%Y%-%m') AND DATE_FORMAT(CURRENT_DATE(), '%Y%-%m')
ORDER BY pagamentos.mesReferencia
How to do this?