Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to use an integer value in a WHERE clause (looking at an integer field).

expression = "'SERVICE' = 'Service' "
expression = expression + 'AND '
expression = expression + "'GPS_TIME_TOTAL' > " + "%d" % 10

This code (using the %d) gives me 'ExecuteError: ERROR 000358: Invalid expression'

When I use %s and '', it runs OK but doesn't give me any records because it's looking into a integer field to find a string.

'SERVICE' = 'Service' AND 'GPS_TIME_TOTAL' > '10'

Any ideas?

share|improve this question
post your solution as an answer to your question(then mark it). so it can help people who faces the same problem. – Aragon Apr 24 '13 at 11:46
Aragon is suggesting that instead of editing your question with the solution, paste the solution into "Your Answer", then mark that answer as accepted. This way future readers will know what worked, and won't confuse the solution with the original question. Thanks. – user3461 Apr 24 '13 at 15:06
OK - it says I can accept my own answer in 2 days – Mike Apr 24 '13 at 16:06

Try this

sql = '"SERVICE" = \'Service\' AND "GPS_TIME_TOTAL" > %d' % 10
share|improve this answer
up vote 0 down vote accepted

Found a solution. I built it up in Arcmap and got the python snippit... turns out using docstring will work

expression = expression + '''"GPS_TIME_TOTAL" < 15'''
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.