Questions tagged [where-clause]

A WHERE clause is used to select data conditionally, as part of a Structured Query Language (SQL) operation

Filter by
Sorted by
Tagged with
0
votes
3answers
56 views

Using field in place of value in WHERE clause of arcpy.da.SearchCursor()? [closed]

I am developing an ArcPy script in ArcGIS Desktop 10.7 and using a file geodatabase feature class. I have a field called facility_id. I have tried using this field as a string field or as an integer ...
2
votes
0answers
28 views

How can I validate a SQL statement in ArcObjects?

I'm trying to validate the results of a ISQLQueryDialog2, but can't find any out of the box solutions. This particular dialog has a built in validate button, but I would like to programmatically ...
0
votes
1answer
33 views

Using keyword in SelectByAttribute expression?

I've used SearchCursor to return the single value of a record (8 digit number) for row in arcpy.da.SearchCursor(table, ['PID']): if row[0] is not None: ID = row[0] break Now I would like ...
1
vote
1answer
34 views

Trying to add a value in the second row of a table

I am trying to add a specific value to a cell of the second row of a feature-class-table. Doesn't work with my code: #First row rows = arcpy.InsertCursor(tb_value) row = rows.newRow() ...
0
votes
1answer
46 views

Problem with if-statement and whereClause format

I have a program which should count the number of a feature class or the length of a feature class depending on the geometry of the input feature class. This part is working. There are two parameter-...
0
votes
2answers
73 views

Automating Select by location using ArcPy and where_clause?

I have used the code in Coding python loop to select features of polygon layer than are completely contained in group of 11 layers using ArcPy? to automate select by location analysis using ArcPy. I ...
1
vote
2answers
57 views

Where Clause in SelectLayerByAttribute function resulting in invalid expression

All of the attempts below result in ERROR 000358: Invalid expression Any ideas on what I am doing wrong? I am working within a File GDB and with polygons. Attempt 1: def SelectLayer(val): print ...
0
votes
1answer
45 views

Syntax error in Where Clause using .format in arcpy.Select_analysis

I'm having a little trouble understanding the syntax for a Where Clause; e.g., for use in arcpy.Select_analysis(inSHP, clipSHP, where). input is polygon shapefile; Zone_ID field is short integer ...
0
votes
1answer
31 views

Subset a shapefile that excludes certain field values by using NOT in Select by Attribute where clause

I am using ArcPy 2.7 to subset a shapefile. I am trying to use arcpy.Select_analysis to exclude certain features from a shapefile (idle fields denoted as 1401 in the field 'Crop_Type'. my 'Crop_Type' ...
0
votes
1answer
57 views

Using arcpy.makequerytable_management with where clause?

I have a script that works great with selecting dates greater than "my From date" but I can't get the code to work when I want to add a less than to the sql where clause (a to date). I had add the {0}...
1
vote
1answer
74 views

Setting up where_clause to select counties one at a time from feature class using ArcPy?

I need to select a single county at the time from the "counties" feature class. I am using a make feature layer with a where clause. How do I set up the where_clause to select each of the counties in ...
1
vote
1answer
26 views

Using IN Clause to Select By Attributes in ArcPy?

I am working in ArcMap 10.1, trying to write a script to automate the selection of a feature class. I have two input parameters: stop1 = arcpy.GetParameterAsText(0) stop2 = arcpy.GetParameterAsText(1)...
2
votes
1answer
88 views

Same SQL expression works with search cursor but not make feature layer

I need to get features in a File GeoDatabase feature class whose "fieldName" (string field) value matches the value of "strValue" (string variable). While I know there are features satisfying this ...
3
votes
3answers
2k views

Writing ArcPy Update Cursor “Where Clause” that Refers to its own Rows?

I'm using Arc 10.2.2. I have 2 files: "Input_Table.exe" (only 3 columns: "ID", "Lat", and "Lon") "Target_Shapefile.shp" (many columns including the same "ID", "Lat", and "Lon") Any rows in the ...
2
votes
4answers
967 views

Creating queries to select by attribute with arcpy

I'm quite new with arcpy and I'm finding selecting by attribute a bit of a nightmare. There's a problem with my query on the script below [query = "\'Location\' = observer"], but I can't tell what it ...
2
votes
2answers
125 views

Generate an sql WHERE clause from selected features

In ArcGIS Desktop, I can use various tools to interactively select features. These selection tools are handy for making complex selections (tabular or spatial) that would be otherwise cumbersome to ...
1
vote
1answer
888 views

Select by attribute using modulo operation?

In ArcMap 10.5, I want to select the rows where the modulus of the objectid by 3 equals 1. How to write a SQL sentence in select by attribute window? My current query statement is something like ...
0
votes
2answers
362 views

Selecting table records by attribute if in Python list

I would like to create a subset of a table based on values in a Python list that I created from a search cursor. I have not been able to get the where_clause correct and keep getting errors. Here is ...
0
votes
1answer
239 views

What is None argument in sql clause in UpdateCursor?

I have a bit of code that is a groupby iterator. It works well, and I understand most of it, but I am wondering what the None argument does within the sql_clause in the code below. I know this is ...
2
votes
1answer
215 views

Using a variable inside a where clause

I am trying to loop through a list of states, and use each state as a variable within a where clause to select by attribute. Below is the code I am trying to run. Note: I will eventually be running ...
1
vote
0answers
103 views

Where Clause for PgAdmin PostGIS

I'm trying to select streams that are a certain distance away from cities. I have been able to do it for a few, but I would like to do it to the entire column that contains the cities name without ...
0
votes
0answers
27 views

Using where clause for arcgis analysis in ArcPy? [duplicate]

I am trying to write a python code for select analysis. FIPS: column in feature nameofinputfeature whose values needs to be compared with OFIPS OFIPS: variable whose value is known each time the ...
2
votes
1answer
437 views

Using UpdateCursor and Where Clause to manipulate attributes?

I am working on a practice problem, and i have hit a wall. Here is what the question is asking. Write a script that updates the attribute of SIZE with the values ‘Large’ or ‘Small’, depending on ...
0
votes
1answer
417 views

Using list of numbers to Select By Attribute in ArcPy?

I am trying to use Python to select all records whose attribute (which is a number) in a certain field is within a list. I cannot get the syntax correct. my list is: upstream = [9841978, 9842008, ...
1
vote
2answers
190 views

Variable in where clause arcpy.Select

I'm trying to set up a loop that includes using items in the array along with string text to populate the where clause. I'm getting the invalid sql expression for the clause. Here's what I have so ...
2
votes
1answer
4k views

How to address the alias of a sub-query in the where-clause in PostgreSQL/PostGIS?

I have a problem with a Postgres query and can't find a solution in stackexchange or any SQL Documentation. I have two tables in PostGIS, one for streets and one for house-numbers. I now want to find ...
-1
votes
1answer
39 views

Passing where clause with range that will prompt user in arcpy.select_analysis?

I am trying to query the user to enter a price range so that all those which are in his range will be retrieved. choice = input("Enter the budget range:") arcpy.Select_analysis("Zillow_Project.shp", "...
4
votes
2answers
605 views

Create table from results of ST_Intersection queries in PostGIS

I create a query in PostGIS using 'where' clause, and with that a table. now I want to use those attributes to create a intersection with other table... but I don't know how to call the attributes, ...
2
votes
1answer
87 views

Using a Variable in arcpy.SelectLayerByAttribute

I know this is a very basic problem I should be able to solve myself, but I've had no luck. I have a variable I want to use in the query for arcpy.SelectLayerByAttribute, but the line that was working ...
1
vote
1answer
95 views

Using where clause with FeatureClassToFeatureClass?

I want to split the shapefile with a field called FULLNAME and save those records with same FULLNAME to a new shapefile, which is the split by attribute. The following code has an error for the last ...
1
vote
1answer
153 views

Writing where clause for Feature Class To Feature Class in ArcPy?

The following picture shows the table for the shapefile. I need to extract those rows with different values of TotalCT, which means I need to extract the first row into a new shapefile named Value_1....
1
vote
1answer
222 views

Passing where clause as variable to arcpy.SearchCursor() gives ERROR 999999?

I'm having trouble passing my where clause for arcpy.SearchCursor as a variable. The following code successfully generates a query for me: PolyList = "C:\\Users\\korora912\\Desktop\\polygons.shp" ...
1
vote
0answers
33 views

Intersects query with where clause and max time

I am having an issue with this query. I am trying to select the buildings (gta_bldgs) that intersect with gps points (wherez) but when the speed is equal to zero and the most recent (Max devicetime). ...
1
vote
2answers
717 views

Finding values that are different between two tables in MapInfo/MapBasic based on a unique ID

I am comparing 2 tables which are mostly the same but there have been some amendments, in effect comparing a new version to the old one and displaying all the records with changes in a selection table ...
1
vote
1answer
562 views

Create VRT from shapefile using a where clause

I am wondering if there is a way to create a .vrt using a shapefile, but specifying attributes through a where clause. I have made a .vrt from a sub section shapefile (pre selected the tiles and ...
2
votes
1answer
369 views

query.where statement using date range in JS API fails with IE 11 but works fine with Chrome and Firefox

My aim to display point data from a feature layer on ArcGIS for JS map interface. I am successful doing so in Chrome and Firefox, however when I include date in a where condition of a query execute it ...
0
votes
1answer
282 views

Writing Where Clause for text field in arcpy.SelectLayerByAttribute_management()?

I am having problems writing WhereClause for my program. I am using 10.3 arcmap. My layer comes form a file geodatabase. I have this code: mlayer = arcpy.mapping.ListLayers(mxd, "1415_LGA_SpatJ", ...
2
votes
0answers
123 views

Reading feature class attributes with or without quotes in ArcPy?

I'm working on a script that clips a batch of feature classes by a selection made in another feature class. The way it works is by reading the clip feature fields, then allowing the user to select the ...
-1
votes
1answer
112 views

Where Clause looking at two Columns and a RANGE Expression

Using ArcPy I'm Trying to Set up a Where Clause with a RANGE in my "FeatureClassToFeatureClass_conversion" This {Where Clause} needs to Query Two Columns in the data: FEATURE = 'ENVIRONMENT' and ...
1
vote
1answer
63 views

Querying two Separate Columns in ArcPy SQL {where clause}? [duplicate]

Using ArcPy I'm Trying to Set up a Where Clause in my "FeatureClassToFeatureClass_conversion" This {Where Clause} needs to Query Two Columns in the data: FEATURE = 'ENVIRONMENT' and TEMPERATURE &...
2
votes
1answer
457 views

Combining wildcard command along with %s in where clause statement for ArcPy?

I am trying to write a script where the user can search for a five digit zipcode using an input statement and a search cursor. The zipcodes in the file though are nine characters long (i.e. xxxxx-xxxx)...
2
votes
1answer
325 views

Using SelectLayerByAttribute and Where Clause in ArcPy?

I'm trying to select the minimum value from a field to select and export that one feature to a temp shp so I can copy the field data from the point to a line. So far I have this: import arcpy from ...
0
votes
1answer
317 views

MakeFeatureLayer_management where_clause input by the user

I want to convert a script into a toolbox and one of the parameters is selecting cities with a population > than 500000 hab. I'm using the function MakeFeatureLayer_management. How can I do to ...
1
vote
1answer
523 views

Problem with variable for arcpy.select_analysis whereclause

I have a problem with the whereclause on python for arcpy.Select_analysis. I try to use a variable for condition: for row_stat in rows_stat: % for calculated the variable"maxi" ...
1
vote
1answer
1k views

Using numeric variable in where clause of ArcPy SearchCursor?

I know this question has been answered but I am not seeing an adaptation that I can understand. I am trying to use a numeric variable in a where clause and just having a hard time figuring it out. ...
1
vote
2answers
2k views

Debugging SQL in arcpy.da.SearchCursor RuntimeError: An invalid SQL statement was used?

I am going through a python script in arcpy 10.1 to Select a field value (i.e. NEAR_DIST) based on three condition as 1) NEAR_DIST<=radius(i.e.500 or anything from user input) 2) ...
1
vote
2answers
137 views

How to handle list variable in a where clause

I am calling a list of names in from a text file and would like to use each of those to make new layers. I am running into an issue where I get "TypeError: cannot concatenate 'str' and 'list' objects" ...
0
votes
1answer
2k views

arcpy Make Feature Layer using a where clause

From a table of lines and polylines I am I'm building a seperate table of points (nodes) with their X and Y coordinates stored as attributes. I want the nodes to be unique, so I'm checking to see if a ...
3
votes
1answer
374 views

Conditional SQL Query

I've been running a code that searches a desired field in a feature class and performs an specified SQL query based on whether the field is string or double. The variables are just temporary fillers ...
3
votes
3answers
4k views

SearchCursor() fails to read feature class?

I am very new to ArcPy and Python in general. I want write a script to read attribute table from a feature class and merge some data from a csv file into the table. Right now, I am just playing around ...