County and State Isolation

568
3
Jump to solution
12-06-2021 12:23 PM
Labels (1)
TaylorBoles1
New Contributor II

Hello.

I am trying to select certain counties from a few states using the select by attribute tool. I am using census data. I have selected the counties that I want by name, but the problem I am running into is that I do not know how to specify which state I want certain counties selected from. Most county names are unoriginal. I have been trying to go through my attribute table and take out the counties from states that I do not need, but I am wondering if there is an easier way to do this like a script I could write. I tried to write WHERE name (county name) <> whatever county I need OR <> the state fip code that corresponds with it but my expression was no valid. Thanks for you help. 

Here's an example of the code I was using in particular:

NAME <> 'Angelina' Or STATEFP <> ‘48’  

0 Kudos
1 Solution

Accepted Solutions
JayantaPoddar
MVP Esteemed Contributor

The quotes look odd. Please ensure you are using the straight quotes (refer my example above).

In my keyboard, it's the key next to Enter Key. Here check this out.

NAME IN ('Angelina', 'Hardin', 'Jasper', 'Liberty', 'Nacogdoches', 'Polk', 'Sabine', 'San Augustine', 'Shelby', 'Tyler') AND STATE_FIPS = '48'


Think Location

View solution in original post

0 Kudos
3 Replies
JayantaPoddar
MVP Esteemed Contributor

Don't use <> operator for text. Instead use = for single value and IN for multiple values. Also use AND gate for both the arguments to be true. An example is given below (I used County boundaries layer available in Living Atlas).

NAME IN ('Angelina', 'Galveston', 'Garza') AND STATE_FIPS= '48'

 

JayantaPoddar_0-1638824762565.png

 



Think Location
TaylorBoles1
New Contributor II

Hello,

I am still having trouble with that expression. I even changed my source layer to the one you are using to try to fix it. I have attached an image of the error I am getting. Thank you! 🙂

0 Kudos
JayantaPoddar
MVP Esteemed Contributor

The quotes look odd. Please ensure you are using the straight quotes (refer my example above).

In my keyboard, it's the key next to Enter Key. Here check this out.

NAME IN ('Angelina', 'Hardin', 'Jasper', 'Liberty', 'Nacogdoches', 'Polk', 'Sabine', 'San Augustine', 'Shelby', 'Tyler') AND STATE_FIPS = '48'


Think Location
0 Kudos