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

  • 2
    WHERE Length("LeftCityCo") > 7 – Kazuhito Dec 5 '17 at 16:32
  • 1
    WHERE Length("LeftCityCo") > 7 will NOT work in ArcGIS Select by Attributes – NULL.Dude Dec 5 '17 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? – Michael Dec 5 '17 at 19:39
  • oops, sorry... try CHAR_LENGTH("LeftCityCo") > 7 – Kazuhito Dec 6 '17 at 2:17
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

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

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.