Query.Where clause

3483
8
Jump to solution
02-25-2015 10:31 AM
Highlighted
New Contributor

The below statement functions fine in a mapserver query: 

query.where = "STRU_NAME = '" + structure+ "'";

I'd like to switch the " = " to a like statement.  I can't seem to get this statement to return any data:

query.where = "STRU_NAME like '" + structure+"'"; 

Any suggestions?  I'm fairly new to development, probably something easy.

Tags (1)
Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
MVP Esteemed Contributor

William,

  Sorry I had my % in the wrong place (% then single quote).

query.where = "STRU_NAME like '" + structure+ "%'"

View solution in original post

Reply
0 Kudos
8 Replies
Highlighted
MVP Esteemed Contributor

William,

   This should work:

query.where = "STRU_NAME like '" + structure+ "'%";

You need a wild card in the SQL

Reply
0 Kudos
Highlighted
New Contributor

Thanks Robert.  I had tried similar syntax changes like you mention but still have no luck, no data gets returned.

Here is the URL (part of it) that with the modification you mention:

query?f=json&where=STRU_NAME%20like%20'wind'%25&returnGeometry=false

This is the original (=, returns data on exact match).

query?f=json&where=STRU_NAME%20%3D%20'wind'&returnGeometry=false

Looks good to me, not sure where the hangup is.

Reply
0 Kudos
Highlighted
MVP Esteemed Contributor

William,

  Sorry I had my % in the wrong place (% then single quote).

query.where = "STRU_NAME like '" + structure+ "%'"

View solution in original post

Reply
0 Kudos
Highlighted
New Contributor

Robert,

Thanks!  Really appreciate your help (the correction above is working great).

Billy

Reply
0 Kudos
Highlighted
Occasional Contributor III

Hi,

Some time ago I asked a similar question and I am guessing the same answer applies to you.

Can 10.2 answer Oracle where clause?

Statements with LIKE operator are not standardized queries and they are disabled in 10.2+ by default.

ArcGIS Help (10.2, 10.2.1, and 10.2.2)

Hope this explains the issues you are having.

Filip.

Reply
0 Kudos
Highlighted
Occasional Contributor III

What? How can it work?!? Have you disabled the requirement for standardized queries or does it work out of the box?

Filip.

Reply
0 Kudos
Highlighted
New Contributor

Filip,

Thanks for the tip, I'll check this out when I have a moment.

Robert,

One last question... if I were to want to add an AND clause to this could you point me in the right direction?

query.where = "STRU_NAME like '" + stateName+ "%' and BMP_TYPE like '" + bmpType+ "%'";

Reply
0 Kudos
Highlighted
New Contributor

nevermind... answered my own question in that post.  should have tried it first

Reply
0 Kudos