How to select and compare results between two tables?

1

I have the following query

SELECT * FROM usuarios
WHERE NOT EXISTS (SELECT * FROM pagos
WHERE pagos.id = usuarios.id AND mes =< '$mes' AND ano =< '$year' )

I am trying to show or select the users who have not made payments in a range not greater than a month, I can show that the year is different but I can not show it if the month is different, that I may be doing wrong.

    
asked by Alexander Quiroz 04.09.2016 в 17:46
source

1 answer

0

You have complicated yourself a lot. Would not it be easier to choose records of one month in a year directly from payments?

SELECT * FROM pagos 
WHERE mes = '$mes' AND ano = '$year';

Example: link

    
answered by 07.10.2016 / 15:10
source