Ver originalselect * from clientes where t1.idcliente not in( SELECT t2.idcliente FROM clientes as t1 left join pagos as t2 on (t1.idcliente=t2.idcliente) WHERE mes=%s AND year=%s )