1

I would like to make a nested query in a single table by means of parentheses in the Query Builder of ArcGIS.

More specific: I only want to select those Columns which start with TR- and in those I want to select those columns that have the attribute 0 (FieldD) and V and E (FieldB) or own (FieldC).

table

I used the following Syntax:

SELECT * FROM Table WHERE:
FieldA LIKE 'TR_%' AND FieldD = 0 AND FieldB in ('V','B') OR FieldC = 'own'

the problem is that when I use the Operator OR for fieldC ArcGIS also considers KS-

2

You can use the brackets within the query builder to create multiple query's for the same dataset. By using "OR" in between the brackets, this will show the different results within the same layer.

For more information on query building, please see the following link on the ESRI website.

For example:

(FieldA LIKE 'TR_%' AND FieldD = 0 AND FieldB in ('V','B')) OR (FieldA LIKE 'TR_%' AND FieldD = 0 AND FieldB in ('V','B') AND FieldC = 'own')
1

Just put parentheses around the groups that you want to consider together, and everything you want always considered leave separate (or in their own set of parentheses):

FieldA LIKE 'TR_%' AND (FieldD = 0 AND FieldB in ('V','B') OR FieldC = 'own')

Which will select everything that starts TR_ and also meets the criteria within the parentheses.


You might also need to consider whether you need to further break this down:

FieldA LIKE 'TR_%' AND ((FieldD = 0 AND FieldB in ('V','B')) OR FieldC = 'own')

Which will select everything with TR_ that has FieldD = 0 and FieldB in ('V', 'B') OR everything with TR_ that has FieldC = 'own'

or this:

FieldA LIKE 'TR_%' AND FieldD = 0 AND (FieldB in ('V','B') OR FieldC = 'own')

Which will select everything with TR_ and FieldD = 0 and either FieldB in ('V','B') or FieldC = 'own'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.