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

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Dec 5, 2017 at 16:22
4
  • 2
    WHERE Length("LeftCityCo") > 7 Commented Dec 5, 2017 at 16:32
  • 1
    WHERE Length("LeftCityCo") > 7 will NOT work in ArcGIS Select by Attributes Commented 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? Commented Dec 5, 2017 at 19:39
  • oops, sorry... try CHAR_LENGTH("LeftCityCo") > 7 Commented 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

answered Dec 6, 2017 at 21:52
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

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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.