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
1answer
16 views

ArcPy FeatureClassToFeatureClass_conversion invalid SQL statement

I am trying to iterate through a list of where clauses as such: for vc in vcList: print (vc) """"D_Zone" = 1""" """"D_Zone" = 2&...
2
votes
1answer
39 views

Arcpy Python Snippet for SQL “LIKE” expression problem

I am trying to use arcpy.Select_analysis in python code with ArcGIS for straightforward geoprocessing. I have a field called "other tags" in a vector dataset which I want to select any ...
4
votes
1answer
67 views

ArcPy TableToNumPyArray where_clause issue

I am trying to run this code in the Python terminal in ArcGIS, but everytime it throws an error and I can't figure it out. I think it probably has something do with how I construct the SQL where ...
0
votes
1answer
33 views

Why do ArcPy SQL expressions use three double quotes?

I am using ArcGIS Pro 2.4 and I am trying to understand why ArcPy SQL expressions use three double quotes. ESRI's "Specifying a query in Python" page, https://pro.arcgis.com/en/pro-app/arcpy/get-...
2
votes
0answers
35 views

Where_Clause expression working for one FeatureClassToFeatureClass_conversion export but not another

I am attempting to export a feature class to both a shapefile and feature class with a where_clause restriction on particular values within particular fields. I have written a function to take dataset ...
2
votes
0answers
181 views

SQL query fails in arcpy, but works in ArcGIS Pro 'select by attributes' [closed]

I'm building an SQL query in Python that is used to make a feature layer, but the feature layer returns no features, when it should return 1169 features. The query below works on 95% of the data (...
2
votes
1answer
39 views

Determining types of geometry in a single table?

I need to determine whether any tables within my database have more than one geometry type. For example, I want to know if there are Points AND multipoints within the same table. Currently, I have ...
0
votes
0answers
51 views

WHERE clause that's stored in a table: Use it to filter a layer?

I have a workorder management system (WMS). The WMS has functionality that allows users to save queries. The queries are saved in a Oracle database table called QUERY (in a CLAUSE column). An ...
1
vote
0answers
37 views

Use selected features to generate WHERE clause in ArcGIS for Portal

I have a web map in Portal that has a point layer called Work Orders. I believe it's possible to manually select points in the layer by using the Web AppBuilder Select Widget. Using selected points, ...
0
votes
1answer
59 views

Filter layer by pasting in WHERE clause?

I have a web map in Portal that has the Web AppBuilder Filter widget. The map has a point layer in it called Work Orders. I would like to filter the work orders by pasting in a WHERE clause. The ...
0
votes
1answer
49 views

Creating WHERE clause from list using ArcPy

I am creating a new shapefile (a subset of a current shapefile) such that it has all the features whose values in a field ("fclass") is not contained in the field_names list. field_names = ['...
0
votes
3answers
197 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
68 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
43 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
85 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() ...
1
vote
1answer
54 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-...
1
vote
2answers
131 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
77 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
56 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
43 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
139 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
94 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
34 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
101 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
3k 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
2k 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
146 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
1k 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
559 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 ...
1
vote
1answer
575 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
330 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
127 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
32 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
747 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
598 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
249 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
6k 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
46 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
860 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
99 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
141 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
214 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
349 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
919 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
643 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
426 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
365 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
138 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
153 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 ...