2

I just want to include lower() in my query to make it irrespective of case.

When I use this I get an error:

arcpy.SelectLayerByAttribute_management("BurrRidgeTreeInventoryMaster""NEW_SELECTION",' lower("species") like 'maple%'')

And when I use this I get everything selected, not just trees that contain 'maple%'

arcpy.SelectLayerByAttribute_management("BurrRidgeTreeInventoryMaster","NEW_SELECTION"," lower('species') like 'maple%'")

What do I have wrong?

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Mar 17, 2017 at 17:54
3
  • Try leaving off the quote marks around your field name e.g. """ lower(species) like 'maple%' """ Commented Mar 17, 2017 at 17:56
  • That said, a SQL query ignores case, so it shouldn't make any difference Commented Mar 17, 2017 at 17:57
  • actually when I leave out the lower the query is successful but it returns 0 entries as opposed to hundreds with lower Commented Mar 17, 2017 at 18:00

1 Answer 1

2

Try leaving off the quote marks around your field name e.g. """ lower(species) like 'maple%' """

arcpy.SelectLayerByAttribute_management("BurrRidgeTreeInventoryMaster","NEW_SELECTION",""" lower(species) like 'maple%' """)

The triple quotes around the query """ this like 'that' """ enables you to include different quote marks in python as required without it breaking your code.

The Where Clause in a arcpy.SelectLayerByAttribute_management() is a SQL query and case should be irrelevant here, so I'm surprised it makes any difference.

answered Mar 17, 2017 at 18:12

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.