3

enter image description hereI am attempting to execute a Select query in Select By Attributes where the return record set I'm looking for includes all records where the String value is greater than 7 characters long.

For ex., I have records in my table where the value in the "LeftCityCo" field is 2395187, and other records where the value in the "LeftCityCo" field is 2395934ANO. I'm seeking to obtain a Selection that includes all records with values in this field greater than 7 characters long.

I've tried using the Left function and attempted the following query but returned an error:

Select * From Streets Where "LeftCityCo" = Left( "LeftCityCo", 7 )enter image description here

4
  • 2
    WHERE Length("LeftCityCo") > 7
    – Kazuhito
    Dec 5, 2017 at 16:32
  • 1
    WHERE Length("LeftCityCo") > 7 will NOT work in ArcGIS Select by Attributes
    – NULL.Dude
    Dec 5, 2017 at 17:56
  • I tried the Where clause suggested and correct, it did not work. Thank you all for your suggestions. Would anyone have any further ideas on how to obtain this Selection set in ArcGIS?
    – Ms05
    Dec 5, 2017 at 19:39
  • oops, sorry... try CHAR_LENGTH("LeftCityCo") > 7
    – Kazuhito
    Dec 6, 2017 at 2:17

2 Answers 2

1

I did not have my code syntactically correct for my Select By Attributes query box. Because I was using this ui, I needed to change my expression to suit file types such as shapefile, File GDB and so on. I was attempting to use SQL syntax and that was incorrect.

Below is the code expression that returned the result I was expecting:

CHAR_LENGTH( "LeftCityCo" ) > 7

0

Open the Select by Attributes window for the appropriate table and use the following expression

len("LeftCityCo") > 7

Quotes around the fieldname were not required with my data set but yours may be enter image description here

12
  • I still get "An invalid SQL statement was used." when attempting that expression.
    – Ms05
    Dec 5, 2017 at 19:43
  • Can you show me exactly (picture) of the attribute table with that field showing
    – NULL.Dude
    Dec 5, 2017 at 19:47
  • How do I post a screen capture?
    – Ms05
    Dec 5, 2017 at 19:54
  • Edit your question to include the image. You can upload directly from your pc
    – NULL.Dude
    Dec 5, 2017 at 19:55
  • Image added to Question.
    – Ms05
    Dec 5, 2017 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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