Query.Where clause

4010
8
Jump to solution
02-25-2015 10:31 AM
WilliamMeredith
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)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

William,

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

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

View solution in original post

0 Kudos
8 Replies
RobertScheitlin__GISP
MVP Emeritus

William,

   This should work:

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

You need a wild card in the SQL

0 Kudos
WilliamMeredith
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.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

William,

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

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

0 Kudos
WilliamMeredith
New Contributor

Robert,

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

Billy

0 Kudos
FilipKrál
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.

0 Kudos
FilipKrál
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.

0 Kudos
WilliamMeredith
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+ "%'";

0 Kudos
WilliamMeredith
New Contributor

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

0 Kudos