get the affectedrows of the correct query