Using a SQL experssion in the "Select by Attributes" table, how would I only select records 1, 4, 5, 8 and omit the rest (I only want to select values that are entirely numbers)? What I have right now is SUBSTRING(address,1,1)<='9' AND SUBSTRING(address,1,1)<> ' ', but it won't catch record 2(1234 S Complex).

enter image description here

  • 1
    You may try to look for question about "regular expression" or "regex" as I think this is the tool for your use case (don't know it well enough to help you with it)
    – J.R
    Oct 5 '18 at 14:42
  • 2
    To clarify, you want to only select the records whose 'address' attribute value contains only numbers (no letters at all)?
    – cmrRose
    Oct 5 '18 at 14:43
  • Correct cmrROse, just numbers. I can't believe this has been this difficult.
    – GIS_GOD
    Oct 5 '18 at 14:46
  • Since you want to have ONLY numbers, one workaround is to create a separate column and use the field calculator (which can accept Python expressions in a codeblock). The expression .isdigit() would check all values, not just the starting character.
    – smiller
    Oct 5 '18 at 15:35
  • 1
    I suggest editing your question to include the storage format of your feature class: shapefile, file/personal geodatabase, DBMS, etc.
    – Andy
    Oct 5 '18 at 16:35

Here is a suggestion:

CAST(address AS INTEGER) >= 0

  • This worked like a charm, thank you. How does this not select a value like '1234 S Complex'? I'm just curious as to how it works.
    – GIS_GOD
    Oct 10 '18 at 16:06

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.