 <p>I put your code on jsFiddle (with my correction): <a href="http://jsfiddle.net/odi86/6jvG4/" rel="nofollow">http://jsfiddle.net/odi86/6jvG4/</a></p> <p>You forgot to add the <code>from</code> clause to your filter, if you add it it works just fine:</p> <pre class="lang-js prettyprint-override"><code>if (filter === "UEU") { layer.setOptions({ query: { select: "'geometry'", from: '4756019', where: "'UEU' = '" + searchString + "'" } }); } else if (filter === "SUBUEU") { layer.setOptions({ query: { select: "'geometry'", from: '4756019', where: "'SUBUEU' = '" + searchString + "'" } }); } else if (filter === "CODIGO") { layer.setOptions({ query: { select: "'geometry'", from: '4756019', where: "'CODIGO' = '" + searchString + "'" } }); } </code></pre> <p>By the way: you can simplify your code a lot by just doing this (not if-else necessary):</p> <pre class="lang-js prettyprint-override"><code>layer.setOptions({ query: { select: "'geometry'", from: '4756019', where: "'" + filter + "' = '" + searchString + "'" } }); </code></pre>