SQL Query in labeling

6907
8
Jump to solution
03-20-2014 04:35 AM
ELTerrell
New Contributor III
Hi all,

I have 10 cities within a county and I'm trying to label 9 of them.  I thought an SQL query in the label feature would eliminate the one I didn't want labeled.  I thought it should look something like this "Name" = 'New York' AND 'Los Angeles' and just leave out the one I don't want?
0 Kudos
1 Solution

Accepted Solutions
MichaelVolz
Esteemed Contributor
Does ArcGIS Explorer Desktop have classes for labels like ArcMap does?  If so, you can add a SQL Query there, that should allow either the syntax:

"Name" = 'New York' OR "Name" = 'Los Angeles'

or

"Name" in ('New York', 'Los Angeles')

View solution in original post

0 Kudos
8 Replies
ELTerrell
New Contributor III
So I found a solution although it wasn't the one I anticipated.  I "added label classes from symbology categories" after having deleted the one city from symbology.

However, I'm thinking there has to be a way to label those using SQL query.
0 Kudos
MichaelVolz
Esteemed Contributor
How about OR instead of AND?
0 Kudos
ELTerrell
New Contributor III
I tried that, I still get an error message.  I also tried IS.  I can only think that maybe it has something to do with the quotations?
0 Kudos
MichaelVolz
Esteemed Contributor
Does ArcGIS Explorer Desktop have classes for labels like ArcMap does?  If so, you can add a SQL Query there, that should allow either the syntax:

"Name" = 'New York' OR "Name" = 'Los Angeles'

or

"Name" in ('New York', 'Los Angeles')
0 Kudos
ELTerrell
New Contributor III
That worked...I just needed the second 'Name' instead of Name = New York OR Los Angeles.
0 Kudos
BenVan_Kesteren1
Occasional Contributor III
"Name" in ('New York', 'Los Angeles')

This is the SQL I use often as sometimes the list can get quite long, and writing "Name" = XXX OR  "Name" = XXX OR... over and over gets tedious 😄
0 Kudos
ELTerrell
New Contributor III
Thanks Ben!  I'll try that next.
0 Kudos
EllenBryson2
Occasional Contributor

Michael made a great suggestion with the IN function.

If you're wondering how to fix your original query, here's the solution.

"Name" = 'New York' OR "Name" = 'Los Angeles'

You need to mention the field name twice. And in this context I think the OR is what you want.