Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Little SQL query help please

$
0
0
I always seem to get hung up on these simple strings.

Here again I don’t quite get the syntax for use in SelectLayerByAttribute_management

If I use the following with a field named “Name” the query works just fine

Code:

iQuery = ' "Name" = \'Joe Blogs\' '
arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", iQuery)

However when I try to use a variable I can never seem to get the syntax right

Code:

iPerson = “Joe Blogs”
iQuery = '"Name" = "' + aCenterMapOn + '"'
arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", iQuery)

Thanks

Viewing all articles
Browse latest Browse all 2485

Trending Articles