<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Invalid Expression or Syntax Error in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14847#M1143</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Writing a python script and attempting to use the SelectLayerByAttribute_management command.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried it several different ways and keep getting a syntax error on the variable set, or if the variable set works, get invalid expression.&amp;nbsp; I am querying against a file geodatabase.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;python snippet:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;where_clause = (r"Status = 'U'")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByAttribute_management("Crimes", "NEW_SELECTION", where_clause)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'd like to add .outputCount to this to see if there are any rows selected.&amp;nbsp; I have done this once in the python window but can't remember how I did it now and didn't put it in my script when it worked.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've also tried various ways of putting quotes and single quotes with and without the r or the parenthesis.&amp;nbsp; Syntax error or it doesn't get passed properly to the query and gives the Invalid expression.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Help!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Forgot to add:&amp;nbsp; In the ArcMap window using the Select by Attributes dialog, the proper syntax is "Status" = 'U' and it works as expected.&amp;nbsp; Just can't get the translation to python to work properly.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 10 Aug 2011 16:13:43 GMT</pubDate>
    <dc:creator>LorindaGilbert</dc:creator>
    <dc:date>2011-08-10T16:13:43Z</dc:date>
    <item>
      <title>Invalid Expression or Syntax Error</title>
      <link>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14847#M1143</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Writing a python script and attempting to use the SelectLayerByAttribute_management command.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried it several different ways and keep getting a syntax error on the variable set, or if the variable set works, get invalid expression.&amp;nbsp; I am querying against a file geodatabase.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;python snippet:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;where_clause = (r"Status = 'U'")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByAttribute_management("Crimes", "NEW_SELECTION", where_clause)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'd like to add .outputCount to this to see if there are any rows selected.&amp;nbsp; I have done this once in the python window but can't remember how I did it now and didn't put it in my script when it worked.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've also tried various ways of putting quotes and single quotes with and without the r or the parenthesis.&amp;nbsp; Syntax error or it doesn't get passed properly to the query and gives the Invalid expression.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Help!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Forgot to add:&amp;nbsp; In the ArcMap window using the Select by Attributes dialog, the proper syntax is "Status" = 'U' and it works as expected.&amp;nbsp; Just can't get the translation to python to work properly.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Aug 2011 16:13:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14847#M1143</guid>
      <dc:creator>LorindaGilbert</dc:creator>
      <dc:date>2011-08-10T16:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Expression or Syntax Error</title>
      <link>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14848#M1144</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Take a look at the example script below.&amp;nbsp; Also, be sure to execute the make a feature layer before executing the 'arcpy.SelectbyAttribute_management' function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;where_clause = ("Status = 'U'")

arcpy.MakeFeatureLayer_management("Crimes", "Crimes_Lyr")

arcpy.SelectLayerByAttribute_management("Crimes_Lyr", "NEW_SELECTION", where_clause)

print arcpy.GetCount_management("Crimes_Lyr")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can also use the 'arcpy.FieldDelimiters' function to get the correct syntax of the field:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
fld = arcpy.AddFieldDelimiters("Crimes", "Status")

where_clause = (fld + " = 'U'")

arcpy.MakeFeatureLayer_management("Crimes", "Crimes_Lyr")

arcpy.SelectLayerByAttribute_management("Crimes_Lyr", "NEW_SELECTION", where_clause)

print arcpy.GetCount_management("Crimes_Lyr")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:35:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14848#M1144</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-10T20:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Expression or Syntax Error</title>
      <link>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14849#M1145</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Writing a python script and attempting to use the SelectLayerByAttribute_management command.&lt;BR /&gt;I've tried it several different ways and keep getting a syntax error on the variable set, or if the variable set works, get invalid expression.&amp;nbsp; I am querying against a file geodatabase.&lt;BR /&gt;&lt;BR /&gt;python snippet:&lt;BR /&gt;&lt;BR /&gt;where_clause = (r"Status = 'U'")&lt;BR /&gt;&lt;BR /&gt;arcpy.SelectLayerByAttribute_management("Crimes", "NEW_SELECTION", where_clause)&lt;BR /&gt;&lt;BR /&gt;I'd like to add .outputCount to this to see if there are any rows selected.&amp;nbsp; I have done this once in the python window but can't remember how I did it now and didn't put it in my script when it worked.&lt;BR /&gt;&lt;BR /&gt;I've also tried various ways of putting quotes and single quotes with and without the r or the parenthesis.&amp;nbsp; Syntax error or it doesn't get passed properly to the query and gives the Invalid expression.&lt;BR /&gt;&lt;BR /&gt;Help!&lt;BR /&gt;&lt;BR /&gt;Forgot to add:&amp;nbsp; In the ArcMap window using the Select by Attributes dialog, the proper syntax is "Status" = 'U' and it works as expected.&amp;nbsp; Just can't get the translation to python to work properly.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If the layer came from file GDB, your where_clause ="Status" ='U' should work. One way you can test is using string literal in the function:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.SelectLayerByAttribute_management("Crimes", "NEW_SELECTION", "\"Status\"='U'")
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:35:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14849#M1145</guid>
      <dc:creator>HemingZhu</dc:creator>
      <dc:date>2021-12-10T20:35:47Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Expression or Syntax Error</title>
      <link>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14850#M1146</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Tried that, it worked great in the python window.&amp;nbsp; Added to the script that will be a tool in ArcMap and it failed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Running script ProcessCAUFile...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;class 'arcgisscripting.ExecuteError'&amp;gt;: ERROR 000622: Failed to execute (Make Feature Layer). Parameters are not valid.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000628: Cannot set input into parameter in_features.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (ProcessCAUFile).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The ultimate goal is to produce a tool for the toolbar in ArcMap.&amp;nbsp; I keep getting where the python scripting works fine in the python window and then fails in the script.&amp;nbsp; I am using the create tool wizard, have it run python script in process.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The reason that I am looking for a number output from the selection query is to see if all features geocoded.&amp;nbsp; If the number of rows is greater than 0, then the user needs to run the rematch/review tool, otherwise it tells them that all geocoded and they can proceed to the next step - another tool on the toolbar that copies the geocoded data for archiving and appends it to a yearly file for mapping - this one actually works.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Aug 2011 17:36:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14850#M1146</guid>
      <dc:creator>LorindaGilbert</dc:creator>
      <dc:date>2011-08-10T17:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Expression or Syntax Error</title>
      <link>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14851#M1147</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am having a similar problem when trying to write a where clause that contains multiple fields and connectors.&amp;nbsp; I have 3 address fields that I would like to select and then zoom to the selected parcel. I think it's an issue with double or single quotes around the entire string, but I haven't figured out the solution. I've read on a few sites that numeric values do not need quotes so I left those off of the number.&amp;nbsp; I also tried using them and the script also did not work.&amp;nbsp; Here's what I have now that does not work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Select by Attributes&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;parcels = "C:\PreApp Maps\Parcels.lyr"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;whereClause = '"ADDRNO"&amp;nbsp; = 1930 AND "ADDRSTREET" = 'BIG OWL' AND "ADDRSUFFIX"&amp;nbsp; = 'ROAD''&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByAttribute_management (parcels, "NEW_SELECTION", whereClause)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Zoom to Selected&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument(r"Current")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df = arcpy.mapping.ListDataFrames(mxd, "Boulder County")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df.zoomToSelectedFeatures()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.RefreshActiveView()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The original source for the parcels layer is on sde not a personal geodatabase so I'm pretty sure I'd use some sort of quotes instead of brackets.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Aug 2011 18:09:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14851#M1147</guid>
      <dc:creator>MollyWatson</dc:creator>
      <dc:date>2011-08-11T18:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Expression or Syntax Error</title>
      <link>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14852#M1148</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Assuming the ADDRNO field is numeric and the others are text, try this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;whereClause = "ADDRNO = 1930 AND ADDRSTREET = 'BIG OWL' AND ADDRSUFFIX = 'ROAD'"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Since I think v9.1 or so you don't have to put quotes and backslashes around the field names. When you export scripts out of ModelBuilder it seems to keep these old school formatting faux pass for seme reason. You don't need them!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Aug 2011 19:54:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14852#M1148</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2011-08-11T19:54:12Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Expression or Syntax Error</title>
      <link>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14853#M1149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the suggestion.&amp;nbsp; When I tried it, I got a new error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;class 'arcgisscripting.ExecuteError'&amp;gt;: Failed to execute. Parameters are not valid.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000825: The value is not a layer or table view&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000840: The value is not a Raster Layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000840: The value is not a Mosaic Layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (SelectLayerByAttribute).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (TestAddressZoomTo).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any other suggestions? Again, I am trying to select 3 address fields and zoom to the selected feature. The first field is numeric, the other 2 fields are text.&amp;nbsp; I also tried changing the script so that the 3 fields were user defined parameters.&amp;nbsp; Then I used the GetParameterAsText function within the SelectLayerByAttribute where clause.&amp;nbsp; I got the same error as listed above. Here is the revised script I was trying:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Script arguments&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PAR1 = arcpy.GetParameterAsText(0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PAR2 = arcpy.GetParameterAsText(1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PAR3 = arcpy.GetParameterAsText(2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Select by Attributes&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;parcels = "C:\PreApp Maps\Parcels.lyr"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;whereClause = "ADDRNO = PAR1 AND ADDRSTREET = PAR2 AND ADDRSUFFIX = PAR3"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByAttribute_management (parcels, "NEW_SELECTION", whereClause)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#Zoom to Selected&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument(r"Current")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df = arcpy.mapping.ListDataFrames(mxd, "Boulder County")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df.zoomToSelectedFeatures()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#arcpy.RefreshActiveView()&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Aug 2011 15:55:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14853#M1149</guid>
      <dc:creator>MollyWatson</dc:creator>
      <dc:date>2011-08-15T15:55:32Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Expression or Syntax Error</title>
      <link>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14854#M1150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Thanks for the suggestion.&amp;nbsp; When I tried it, I got a new error:&lt;BR /&gt;&lt;BR /&gt;&amp;lt;class 'arcgisscripting.ExecuteError'&amp;gt;: Failed to execute. Parameters are not valid.&lt;BR /&gt;ERROR 000825: The value is not a layer or table view&lt;BR /&gt;ERROR 000840: The value is not a Raster Layer.&lt;BR /&gt;ERROR 000840: The value is not a Mosaic Layer.&lt;BR /&gt;Failed to execute (SelectLayerByAttribute).&lt;BR /&gt;&lt;BR /&gt;Failed to execute (TestAddressZoomTo).&lt;BR /&gt;&lt;BR /&gt;Any other suggestions? Again, I am trying to select 3 address fields and zoom to the selected feature. The first field is numeric, the other 2 fields are text.&amp;nbsp; I also tried changing the script so that the 3 fields were user defined parameters.&amp;nbsp; Then I used the GetParameterAsText function within the SelectLayerByAttribute where clause.&amp;nbsp; I got the same error as listed above. Here is the revised script I was trying:&lt;BR /&gt;&lt;BR /&gt;# Script arguments&lt;BR /&gt;PAR1 = arcpy.GetParameterAsText(0)&lt;BR /&gt;PAR2 = arcpy.GetParameterAsText(1)&lt;BR /&gt;PAR3 = arcpy.GetParameterAsText(2)&lt;BR /&gt;&lt;BR /&gt;#Select by Attributes&lt;BR /&gt;parcels = "C:\PreApp Maps\Parcels.lyr"&lt;BR /&gt;whereClause = "ADDRNO = PAR1 AND ADDRSTREET = PAR2 AND ADDRSUFFIX = PAR3"&lt;BR /&gt;arcpy.SelectLayerByAttribute_management (parcels, "NEW_SELECTION", whereClause)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;#Zoom to Selected&lt;BR /&gt;mxd = arcpy.mapping.MapDocument(r"Current")&lt;BR /&gt;df = arcpy.mapping.ListDataFrames(mxd, "Boulder County")[0]&lt;BR /&gt;df.zoomToSelectedFeatures()&lt;BR /&gt;#arcpy.RefreshActiveView()&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Based on your error message, it looks like it doesn't recognize parcels as a feature layer or table view. Either check parcels path make sure its souce is accessible or make a layer explicitly:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
arcpy.env.workspace ="C:\PreApp Maps"
arcpy.MakeFeatureLayer_management("Parcels", "lyr")
...
arcpy.SelectLayerByAttribute_management ("lyr", "NEW_SELECTION", whereClause)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:35:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14854#M1150</guid>
      <dc:creator>HemingZhu</dc:creator>
      <dc:date>2021-12-10T20:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Expression or Syntax Error</title>
      <link>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14855#M1151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the suggestion.&amp;nbsp; When I tried the MakeFeatureLayer it still did not work. I think there is an issue with the parcel feature class being located on SDE.&amp;nbsp; So I exported a copy and saved it as a shapefile. The MakeFeatureLayer function then worked. However, I am still getting an error 00358 invalid expression when it gets to the whereClause for the SelectLayerByAttribute.&amp;nbsp; Again, here's what the whereClause expression is now that does not work: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Script arguments&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PAR1 = arcpy.GetParameterAsText(0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PAR2 = arcpy.GetParameterAsText(1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PAR3 = arcpy.GetParameterAsText(2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Select by Attributes&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.workspace ="C:\PreApp Maps"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.MakeFeatureLayer_management("Parcels.shp", "parcels_lyr")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;whereClause = "ADDRNO = PAR1 AND ADDRSTREET = PAR2 AND ADDRSUFFIX = PAR3"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByAttribute_management ("parcels_lyr", "NEW_SELECTION", whereClause)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Aug 2011 20:21:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14855#M1151</guid>
      <dc:creator>MollyWatson</dc:creator>
      <dc:date>2011-08-15T20:21:01Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Expression or Syntax Error</title>
      <link>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14856#M1152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;have you tested the query through the standard select by attributes interface in ArcMap?&amp;nbsp; Have you tried it incrementally (ie add one piece, then the second etc)?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Aug 2011 21:21:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14856#M1152</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2011-08-15T21:21:06Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Expression or Syntax Error</title>
      <link>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14857#M1153</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;have you tested the query through the standard select by attributes interface in ArcMap?&amp;nbsp; Have you tried it incrementally (ie add one piece, then the second etc)?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You stated that your first field is a numeric. If that is the case, you need parse you first parameter to a numeric. something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PAR1 = arcpy.GetParameterAsText(0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# don't know what your numeric type is, so just put int here for demo &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PAR1_int =int(PAR1) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;whereClause = "ADDRNO = PAR1_int AND ADDRSTREET = PAR2 AND ADDRSUFFIX = PAR3"&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Aug 2011 12:33:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14857#M1153</guid>
      <dc:creator>HemingZhu</dc:creator>
      <dc:date>2011-08-16T12:33:48Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Expression or Syntax Error</title>
      <link>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14858#M1154</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I tried inserting the parse phrase as suggested and I still get this error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;class 'arcgisscripting.ExecuteError'&amp;gt;: ERROR 000358: Invalid expression&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (SelectLayerByAttribute).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I verified the whereClause using the manual select by attribute box and it verified successfully and selected the correct parcel.&amp;nbsp; This is the example where clause I took from the selection box:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"ADDRNO" = 2 AND "ADDRSTREET" = 'PONDEROSA' AND "ADDRSUFFIX" = 'LANE'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So based on this it does appear that the field names need quotes.&amp;nbsp; However, when I put double quotes around the entire string it still does not work. I tried the following to enclose the string and I get invalid syntax errors for all:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;""ADDRNO" = 2 AND "ADDRSTREET" = 'PONDEROSA' AND "ADDRSUFFIX" = 'LANE'" (double quotes)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'"ADDRNO" = 2 AND "ADDRSTREET" = 'PONDEROSA' AND "ADDRSUFFIX" = 'LANE'' (single quotes)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'"ADDRNO" = 2 AND "ADDRSTREET" = 'PONDEROSA' AND "ADDRSUFFIX" = 'LANE'" (single beginning, double end)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"ADDRNO" = 2 AND "ADDRSTREET" = 'PONDEROSA' AND "ADDRSUFFIX" = 'LANE' (no quotes)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I remove the quotes from around the field names, the script says it is completed successfully, yet no parcel is selected in the parcel layer.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Aug 2011 15:27:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14858#M1154</guid>
      <dc:creator>MollyWatson</dc:creator>
      <dc:date>2011-08-16T15:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Expression or Syntax Error</title>
      <link>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14859#M1155</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You will either need to escape your double-quotes with backslashes or single-quotes. Backslashes are probably the most obvious:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;"\"ADDRNO\" = 2 AND \"ADDRSTREET\" = 'PONDEROSA' AND \"ADDRSUFFIX\" = 'LANE'"&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Aug 2011 16:23:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14859#M1155</guid>
      <dc:creator>LoganPugh</dc:creator>
      <dc:date>2011-08-16T16:23:59Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Expression or Syntax Error</title>
      <link>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14860#M1156</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;You will either need to escape your double-quotes with backslashes or single-quotes. Backslashes are probably the most obvious:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;"\"ADDRNO\" = 2 AND \"ADDRSTREET\" = 'PONDEROSA' AND \"ADDRSUFFIX\" = 'LANE'"&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have successfully used expression in searchCursor. You really don't need quotes (single or double) for field names for arcpy. Not sure why it did not work. If you could post your script and part of data, i will test it myself and get back to you.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Aug 2011 16:40:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14860#M1156</guid>
      <dc:creator>HemingZhu</dc:creator>
      <dc:date>2011-08-16T16:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Expression or Syntax Error</title>
      <link>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14861#M1157</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Attached is a zip file containing a portion of the parcel shapefile.&amp;nbsp; Here is the code I was using to just try to test the Select by Attributes function:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Select by Attributes&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.workspace ="C:\PreApp Maps"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.MakeFeatureLayer_management("Parcels.shp", "parcels_lyr")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;whereClause = "\"ADDRNO\" = 2 AND \"ADDRSTREET\" = 'PONDEROSA' AND \"ADDRSUFFIX\" = 'LANE'"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByAttribute_management ("parcels_lyr", "NEW_SELECTION", whereClause)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ideally, I would like to use 3 user defined parameters to get the parcel selected which I have been using this script that doesn't work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Script arguments&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PAR1 = arcpy.GetParameterAsText(0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PAR2 = arcpy.GetParameterAsText(1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PAR3 = arcpy.GetParameterAsText(2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Parse first parameter to numeric&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PAR1_int =int(PAR1) &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Select by Attributes&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.workspace ="C:\PreApp Maps"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.MakeFeatureLayer_management("Parcels.shp", "parcels_lyr")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;whereClause = "ADDRNO = PAR1_int AND ADDRSTREET = PAR2 AND ADDRSUFFIX = PAR3" &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByAttribute_management ("parcels_lyr", "NEW_SELECTION", whereClause)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Aug 2011 12:51:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14861#M1157</guid>
      <dc:creator>MollyWatson</dc:creator>
      <dc:date>2011-08-17T12:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Expression or Syntax Error</title>
      <link>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14862#M1158</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Your where clause is incorrect, you need to format it as such: "ADDRNO" = 1 AND "ADDRSTREET" = 'GOLD' AND "ADDRSUFFIX" = 'TRAIL', but in the code provided, you do the following: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;whereClause = "ADDRNO = PAR1_int AND ADDRSTREET = PAR2 AND ADDRSUFFIX = PAR3"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
whereClause = "\"ADDRNO\" = " + str(PAR1_int) + " AND \"ADDRSTREET\" = '" + str(PAR2) + "' AND \"ADDRSUFFIX\" = '" + str(PAR3) +"'"
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This also assume that you will always be using a shapefile for the field names.&amp;nbsp; You might want to look at arcpy.AddFieldDelimiters() which will format the fields for you based on the workspace.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Enjoy&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:35:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14862#M1158</guid>
      <dc:creator>AndrewChapkowski</dc:creator>
      <dc:date>2021-12-10T20:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Expression or Syntax Error</title>
      <link>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14863#M1159</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Andrew, thanks for the suggestion.&amp;nbsp; I tried using your where clause for both Select Layer by Attributes and Search Cursor. Both scripts said they were completed successfully, yet neither selected the parcel defined by the user parameters.&amp;nbsp; When I created the three parameters in the tool properties, I made them strings.&amp;nbsp; Should they be something else?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's the script I have for the Select by Attributes:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Script arguments&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PAR1 = arcpy.GetParameterAsText(0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PAR2 = arcpy.GetParameterAsText(1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PAR3 = arcpy.GetParameterAsText(2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Parse first parameter to numeric&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PAR1_int =int(PAR1) &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Select by Attributes&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.workspace ="C:\PreApp Maps"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.MakeFeatureLayer_management("Parcels.shp", "parcels_lyr")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;whereClause = "\"ADDRNO\" = " + str(PAR1_int) + " AND \"ADDRSTREET\" = '" + str(PAR2) + "' AND \"ADDRSUFFIX\" = '" + str(PAR3) +"'"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByAttribute_management ("parcels_lyr", "NEW_SELECTION", whereClause)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Zoom to Selected&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument(r"Current")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df = arcpy.mapping.ListDataFrames(mxd, "Boulder County")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df.zoomToSelectedFeatures()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.RefreshActiveView()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For the Search Cursor, the first part and last part is the same and here's the middle:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#Search Cursor&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.workspace ="C:\PreApp Maps"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.MakeFeatureLayer_management("Parcels.shp", "parcels_lyr")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;whereClause = whereClause = "\"ADDRNO\" = " + str(PAR1_int) + " AND \"ADDRSTREET\" = '" + str(PAR2) + "' AND \"ADDRSUFFIX\" = '" + str(PAR3) +"'"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;rows = arcpy.SearchCursor("parcels_lyr", whereClause)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Were you able to get it to work with the where Clause you provided? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks everyone for your help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Aug 2011 15:07:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14863#M1159</guid>
      <dc:creator>MollyWatson</dc:creator>
      <dc:date>2011-08-17T15:07:46Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Expression or Syntax Error</title>
      <link>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14864#M1160</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Attached is a zip file containing a portion of the parcel shapefile.&amp;nbsp; Here is the code I was using to just try to test the Select by Attributes function:&lt;BR /&gt;&lt;BR /&gt;#Select by Attributes&lt;BR /&gt;arcpy.env.workspace ="C:\PreApp Maps"&lt;BR /&gt;arcpy.MakeFeatureLayer_management("Parcels.shp", "parcels_lyr")&lt;BR /&gt;whereClause = "\"ADDRNO\" = 2 AND \"ADDRSTREET\" = 'PONDEROSA' AND \"ADDRSUFFIX\" = 'LANE'"&lt;BR /&gt;arcpy.SelectLayerByAttribute_management ("parcels_lyr", "NEW_SELECTION", whereClause)&lt;BR /&gt;&lt;BR /&gt;Ideally, I would like to use 3 user defined parameters to get the parcel selected which I have been using this script that doesn't work:&lt;BR /&gt;&lt;BR /&gt;# Script arguments&lt;BR /&gt;PAR1 = arcpy.GetParameterAsText(0)&lt;BR /&gt;PAR2 = arcpy.GetParameterAsText(1)&lt;BR /&gt;PAR3 = arcpy.GetParameterAsText(2)&lt;BR /&gt;&lt;BR /&gt;#Parse first parameter to numeric&lt;BR /&gt;PAR1_int =int(PAR1) &lt;BR /&gt;&lt;BR /&gt;#Select by Attributes&lt;BR /&gt;arcpy.env.workspace ="C:\PreApp Maps"&lt;BR /&gt;arcpy.MakeFeatureLayer_management("Parcels.shp", "parcels_lyr")&lt;BR /&gt;whereClause = "ADDRNO = PAR1_int AND ADDRSTREET = PAR2 AND ADDRSUFFIX = PAR3" &lt;BR /&gt;arcpy.SelectLayerByAttribute_management ("parcels_lyr", "NEW_SELECTION", whereClause)&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Molly,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I tested your code, i made a little adjustment. It should worked by the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
PAR1 = arcpy.GetParameterAsText(0)
PAR2 = arcpy.GetParameterAsText(1)
PAR3 = arcpy.GetParameterAsText(2)

#Select by Attributes
arcpy.env.workspace ="C:\PreApp Maps"
arcpy.MakeFeatureLayer_management("Parcels.shp", "parcels_lyr")
whereClause = "ADDRNO =" + PAR1 +" AND ADDRSTREET = '"+ PAR2+"' AND ADDRSUFFIX ='" + PAR3 +"'" 
arcpy.SelectLayerByAttribute_management ("parcels_lyr", "NEW_SELECTION", whereClause)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:35:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14864#M1160</guid>
      <dc:creator>HemingZhu</dc:creator>
      <dc:date>2021-12-10T20:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Expression or Syntax Error</title>
      <link>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14865#M1161</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Were you able to get the code you posted to work? The script runs successfully but no parcel is selected so the map does not zoom to the selected parcel.&amp;nbsp; I copied your code exactly as you posted it and I'm still not successful.&amp;nbsp; I also tried including the "parse first paramter to numeric" suggestion as mentioned on 8/16/2011 but then I get an error that that it cannot concatenate 'str' and 'int' objects.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Aug 2011 18:40:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14865#M1161</guid>
      <dc:creator>MollyWatson</dc:creator>
      <dc:date>2011-08-22T18:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Expression or Syntax Error</title>
      <link>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14866#M1162</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Were you able to get the code you posted to work? The script runs successfully but no parcel is selected so the map does not zoom to the selected parcel.&amp;nbsp; I copied your code exactly as you posted it and I'm still not successful.&amp;nbsp; I also tried including the "parse first paramter to numeric" suggestion as mentioned on 8/16/2011 but then I get an error that that it cannot concatenate 'str' and 'int' objects.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Sorry for late reply. Yes i indeed got results. You can test it on a .mxd using the script as as layer.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Aug 2011 20:41:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/invalid-expression-or-syntax-error/m-p/14866#M1162</guid>
      <dc:creator>HemingZhu</dc:creator>
      <dc:date>2011-08-29T20:41:29Z</dc:date>
    </item>
  </channel>
</rss>

