Sql query column dynamic placeholder

I wasn’t too sure what to name the subject line for this question.
I am trying to run a query within a FOR loop
and every time it comes through here, I am not returning the correct results because something

FOR x in range(1,6): x=str(x) query1 = "SELECT BatchID FROM Reports WHERE TempZone"+ x + " = NULL" batchID = system.db.runScalarQuery(query1)

The problem is the indirect column named TempZone1-5
Does anyone know a way around this?
I’ve already tried

system.db.runScalarQuery("Select BatchID From Reports Where TempZone%s = NULL" %x)

It didn’t work either.

You can’t use comparisons (=, <>, >, <) when checking for NULL. You need to use IS NULL or IS NOT NULL

Try -

FOR x in range(1,6): x=str(x) query1 = "SELECT BatchID FROM Reports WHERE TempZone"+ x + " IS NULL" batchID = system.db.runScalarQuery(query1)

You can bypass the str(x) and use the following:

for x in range(1,6): query1 = "SELECT BatchID FROM Reports WHERE TempZone%d is NULL"%(x) batchID = system.db.runScalarQuery(query1)