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

When I run this code, it says "An invalid SQL statement was used". Any idea what does it mean?

import arcpy
from arcpy import env

env.workspace ="C:/RG/Projects/CriticalDataNetwork/CDEC.gdb"

    inTable = "Avg_Daily"
    keyField = "STATION_ID"
    inField = [["Avg_Daily.OBJECTID","OBJECTID",],["Avg_Daily.STATION_ID","STATION_ID"],   ["Avg_Daily.DLY_AVG", "DLY_AVG"]]
    whereClause = "\"STATION_ID\" = 'CAP', 'DDM'"
    outTable = "Test"
    print outTable

    arcpy.MakeQueryTable_management(inTable,  outTable, "USE_KEY_FIELDS", keyField, inField, whereClause)

except Exception, e:
    # If an error occurred, print line number and error message
    import traceback, sys
    tb = sys.exc_info()[2]
    print "Line %i" % tb.tb_lineno
    print e.message
share|improve this question
up vote 3 down vote accepted

you cannot use equal with more than one value

use either in or OR to do this

"\"STATION_ID\" IN ('CAP', 'DDM')"


note that I recommand using """ to clarify your strings

""" "STATION_ID" IN ('CAP', 'DDM') """

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.