Allow non sequential flag numbers

If flag numbers are non sequential (eg someone removed one flag because
it wasn't needed anymore), the SQL generated still will include all
possible integers. Before, it was missing some.