<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta content="text/html; charset=utf-8">
<meta name="Title" content="">
<meta name="Keywords" content="">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style>
<!--
@font-face
        {font-family:"Cambria Math"}
@font-face
        {font-family:Calibri}
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:Calibri}
a:link, span.MsoHyperlink
        {color:#0563C1;
        text-decoration:underline}
a:visited, span.MsoHyperlinkFollowed
        {color:#954F72;
        text-decoration:underline}
span.EmailStyle17
        {font-family:Calibri;
        color:windowtext}
span.EmailStyle18
        {font-family:Calibri;
        color:windowtext}
span.msoIns
        {text-decoration:underline;
        color:teal}
.MsoChpDefault
        {font-size:10.0pt;
        font-family:Calibri}
@page WordSection1
        {margin:1.0in 1.0in 1.0in 1.0in}
div.WordSection1
        {}
-->
</style>
</head>
<body bgcolor="white" lang="EN-US" link="#0563C1" vlink="#954F72">
<div>
<div style="font-family:Calibri,sans-serif; font-size:11pt">Hi,<br>
<br>
This question in gis.stackexchange is also about using IN in FILTER http://gis.stackexchange.com/questions/214899/in-operator-in-filter-in-my-mapfile/214921#214921. Could they be related?<br>
<br>
-Jukka Rahkonen-</div>
</div>
<div dir="ltr">
<hr>
<span style="font-family:Calibri,sans-serif; font-size:11pt; font-weight:bold">Lähettäjä:
</span><span style="font-family:Calibri,sans-serif; font-size:11pt"><a href="mailto:pmoen@nd.gov">Moen, Paul T.</a></span><br>
<span style="font-family:Calibri,sans-serif; font-size:11pt; font-weight:bold">Lähetetty:
</span><span style="font-family:Calibri,sans-serif; font-size:11pt">‎21.‎10.‎2016 0:31</span><br>
<span style="font-family:Calibri,sans-serif; font-size:11pt; font-weight:bold">Vastaanottaja:
</span><span style="font-family:Calibri,sans-serif; font-size:11pt"><a href="mailto:mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a></span><br>
<span style="font-family:Calibri,sans-serif; font-size:11pt; font-weight:bold">Aihe:
</span><span style="font-family:Calibri,sans-serif; font-size:11pt">[mapserver-users] IN operator via queryByAttribute no longer works in php-mapscript Mapserver 7.0.2</span><br>
<br>
</div>
<div>
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt">I cannot get the IN operator to work with queryByAttributes in the new version of php_mapscript. I see nothing obvious mentioned in the migration guide and have found no examples in the documentation on the
 syntax expected by Mapserver 7.0.2.</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">The following queryByAttribute using an IN clause worked with MapServer version 6.4.2.</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt">queryByAttributes(site_id,(site_id IN (4243,4468,3142)),MS_MULTIPLE);</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">The following select was created.</span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt">msPostGISLayerWhichShapes query: select "site_id","county","station_location","longitude","latitude","status",encode(ST_AsBinary(ST_Force2D("the_geom"),'NDR'),'hex') as geom,"site_id"
 from (select p.site_id,p.the_geom,p.county,p.station_location, p.longitude,p.latitude,p.status from precip.station p) as foo where the_geom && ST_GeomFromText('POLYGON((1026879.66418811 54774.2883737648,1026879.66418811 1331032.73787942,2999091.34586756 1331032.73787942,2999091.34586756
 54774.2883737648,1026879.66418811 54774.2883737648))',2266) and (site_id IN (4243,4468,3142))</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">The same queryByAttribute as above fails with Mapserver version 7.0.2 and listed below is the select statement that is created.</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt">msPostGISLayerWhichShapes query: select "site_id","county","station_location","longitude","latitude","status",encode(ST_AsBinary(ST_Force2D("the_geom"),'NDR'),'hex') as geom,"site_id"
 from (select p.site_id,p.the_geom,p.county,p.station_location, p.longitude,p.latitude,p.status from precip.station p) as foo where the_geom && ST_GeomFromText('POLYGON((1026879.66418811 54774.2883737648,1026879.66418811 1331032.73787942,2999091.34586756 1331032.73787942,2999091.34586756
 54774.2883737648,1026879.66418811 54774.2883737648))',2266) and ((4243.000000,4468.000000,3142.000000))</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">The select statement created by 7.0.2 is incorrect with the parameters that I passed in in the previous version.</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Specifically, the final and of the where clause went from 'and (site_id IN (4243,4468,3142))' to 'and ((4243.000000,4468.000000,3142.000000))'.</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">I then tried to figure out the correct syntax of a mapserver expressions and added brackets around the parameter.</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt">queryByAttributes(site_id,([site_id] IN (4243,4468,3142)),MS_MULTIPLE);</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">This gave the following select statement.</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt">msPostGISLayerWhichShapes query: select "site_id","county","station_location","longitude","latitude","status",encode(ST_AsBinary(ST_Force2D("the_geom"),'NDR'),'hex') as geom,"site_id"
 from (select p.site_id,p.the_geom,p.county,p.station_location, p.longitude,p.latitude,p.status from precip.station p) as foo where the_geom && ST_GeomFromText('POLYGON((1026879.66418811 54774.2883737648,1026879.66418811 1331032.73787942,2999091.34586756 1331032.73787942,2999091.34586756
 54774.2883737648,1026879.66418811 54774.2883737648))',2266) and ("site_id"(4243.000000,4468.000000,3142.000000))</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Now the where clause looks like ("site_id"(4243.000000,4468.000000,3142.000000)). This is close but the IN disappears between site_id and the list of values.</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">The only way I can get this to work is to use a regular expression. This seems like a work around since an integer field is being cast as text in order to do a regular expression.</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt">queryByAttributes(site_id,([site_id] ~* "^(4243|4468|3142)$"),MS_MULTIPLE);</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Resulting select statement.</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt">msPostGISLayerWhichShapes query: select "site_id","county","station_location","longitude","latitude","status",encode(ST_AsBinary(ST_Force2D("the_geom"),'NDR'),'hex') as geom,"site_id"
 from (select p.site_id,p.the_geom,p.county,p.station_location, p.longitude,p.latitude,p.status from precip.station p) as foo where the_geom && ST_GeomFromText('POLYGON((1026879.66418811 54774.2883737648,1026879.66418811 1331032.73787942,2999091.34586756 1331032.73787942,2999091.34586756
 54774.2883737648,1026879.66418811 54774.2883737648))',2266) and ("site_id"::text ~* '^(4243|4468)$')</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">How do I properly format the query string for queryByAttributes to search for an attribute using a where in clause?  Is the regular expression approach the only way to accomplish the search? 
</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Thanks for the help,</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Paul</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">  </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
</div>
</body>
</html>