<html>
<head>
    <base href="https://docs.jboss.org/author">
            <link rel="stylesheet" href="/author/s/en/2172/19/5/_/styles/combined.css?spaceKey=TEIID&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://docs.jboss.org/author/display/TEIID/Criteria">Criteria</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://docs.jboss.org/author/display/~shawkins">Steven Hawkins</a>
    </h4>
        <br/>
                         <h4>Changes (19)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >* Predicates that evaluate to true or false <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >* Logical criteria that combines criteria <span class="diff-changed-words"><span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">\</span>(AND,</span> OR, NOT) <br></td></tr>
            <tr><td class="diff-unchanged" > <br>* A value expression with type boolean <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >* {code:SQL}(criteria){code} <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >* {code:SQL}expression <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">\(=|&lt;&gt;|!=|&lt;|&gt;|&lt;=|&gt;=) \(expression|\((ANY|ALL|SOME)</span> <span class="diff-added-words"style="background-color: #dfd;">(=|&lt;&gt;|!=|&lt;|&gt;|&lt;=|&gt;=) (expression|((ANY|ALL|SOME)</span> subquery)){code} <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-changed-lines" >* {code:SQL}expression <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">\[NOT\]</span> <span class="diff-added-words"style="background-color: #dfd;">[NOT]</span> IS NULL{code} <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">* {code:SQL}expression \[NOT] IN \(expression\[,expression]\*)|subquery{code} <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">* {code:SQL}expression [NOT] IN (expression [,expression]*)|subquery{code} <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-changed-lines" >* {code:SQL}expression <span class="diff-changed-words"><span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">\</span>[NOT]</span> LIKE pattern <span class="diff-changed-words"><span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">\</span>[ESCAPE</span> char]{code} <br></td></tr>
            <tr><td class="diff-unchanged" > <br>Matches the string expression against the given string pattern. The pattern may contain % to match any number of characters and _ to match any single character.  The escape character can be used to escape the match characters % and \_. <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >* {code:SQL}expression <span class="diff-changed-words"><span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">\</span>[NOT]</span> SIMILAR TO pattern <span class="diff-changed-words"><span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">\</span>[ESCAPE</span> char]{code} <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-changed-lines" >SIMILAR TO is a cross between LIKE and standard regular expression syntax.  % and _ are still used, rather than <span class="diff-changed-words">.<span class="diff-added-chars"style="background-color: #dfd;">\</span>*</span> and . respectively. <br></td></tr>
            <tr><td class="diff-unchanged" > <br>{info:title=Note} <br></td></tr>
            <tr><td class="diff-changed-lines" >Teiid does not exhaustively validate SIMILAR TO pattern values.  Rather the pattern is converted to an equivalent regular expression. Care should be taken not to rely on general regular expression features when using SIMILAR TO.  If additional features are needed, then <span class="diff-changed-words">LIKE<span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">\</span>_REGEX</span> should be used. Usage of a <span class="diff-changed-words">non<span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">\</span>-literal</span> pattern is discouraged as pushdown support is limited. <br></td></tr>
            <tr><td class="diff-unchanged" >{info} <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">* {code:SQL}expression \[NOT] LIKE\_REGEX pattern{code} <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">* {code:SQL}expression [NOT] LIKE_REGEX pattern{code} <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-changed-words">LIKE<span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">\</span>_REGEX</span> allows for standard regular expression syntax to be used for matching.  This differs from SIMILAR TO and LIKE in that the escape character is no longer used <span class="diff-changed-words"><span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">\</span>(\</span> is already the standard escape mechanism in regular expressions and % and _ have no special meaning. The runtime engine uses the JRE implementation of regular expressions - see the [java.util.regex.Pattern|http://download.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html] class for details. <br></td></tr>
            <tr><td class="diff-unchanged" > <br>{info:title=Note} <br></td></tr>
            <tr><td class="diff-changed-lines" >Teiid does not exhaustively validate <span class="diff-changed-words">LIKE<span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">\</span>_REGEX</span> pattern values.  It is possible to use JRE only regular expression features that are not specified by the SQL specification.  Additional not all sources support the same regular expression flavor or extensions.  Care should be taken in pushdown situations to ensure that the pattern used will have same meaning in Teiid and across all applicable sources. <br></td></tr>
            <tr><td class="diff-unchanged" >{info} <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">* {code:SQL}EXISTS\(subquery){code} <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">* {code:SQL}EXISTS (subquery){code} <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-changed-lines" >* {code:SQL}expression <span class="diff-changed-words"><span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">\</span>[NOT]</span> BETWEEN minExpression AND maxExpression{code} <br></td></tr>
            <tr><td class="diff-unchanged" > <br>Teiid converts BETWEEN into the equivalent form expression &gt;= minExpression AND expression &lt;= maxExpression <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >Syntax Rules: <br> <br></td></tr>
            <tr><td class="diff-unchanged" >* The precedence ordering from lowest to highest is comparison, NOT, AND, OR <br></td></tr>
            <tr><td class="diff-unchanged" > <br>* Criteria nested by parenthesis will be logically evaluated prior to evaluating the parent criteria. <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >Some examples of valid criteria are: <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >* <span class="diff-changed-words"><span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">\</span>(balance</span> &gt; 2500.0) <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-changed-lines" >* <span class="diff-changed-words">100<span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">\</span>*(50</span> - <span class="diff-changed-words">x)/<span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">\</span>(25</span> - y) &gt; z <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-changed-lines" >* <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">concat\(areaCode,concat\(&#39;\-&#39;,phone))</span> <span class="diff-added-words"style="background-color: #dfd;">concat(areaCode,concat(&#39;-&#39;,phone))</span> LIKE &#39;314%1&#39; <br></td></tr>
            <tr><td class="diff-unchanged" > <br>{note:title=Comparing null Values} <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <p>Criteria may be:</p>

<ul>
        <li>Predicates that evaluate to true or false</li>
</ul>


<ul>
        <li>Logical criteria that combines criteria (AND, OR, NOT)</li>
</ul>


<ul>
        <li>A value expression with type boolean</li>
</ul>


<p>Usage:</p>

<ul>
        <li><div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">criteria AND|OR criteria</pre>
</div></div></li>
</ul>


<ul>
        <li><div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">NOT criteria</pre>
</div></div></li>
</ul>


<ul>
        <li><div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">(criteria)</pre>
</div></div></li>
</ul>


<ul>
        <li><div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">expression (=|&lt;&gt;|!=|&lt;|&gt;|&lt;=|&gt;=) (expression|((ANY|ALL|SOME) subquery))</pre>
</div></div></li>
</ul>


<ul>
        <li><div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">expression [NOT] IS NULL</pre>
</div></div></li>
</ul>


<ul>
        <li><div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">expression [NOT] IN (expression [,expression]*)|subquery</pre>
</div></div></li>
</ul>


<ul>
        <li><div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">expression [NOT] LIKE pattern [ESCAPE char]</pre>
</div></div></li>
</ul>


<p>Matches the string expression against the given string pattern. The pattern may contain % to match any number of characters and _ to match any single character.  The escape character can be used to escape the match characters % and &#95;.</p>

<ul>
        <li><div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">expression [NOT] SIMILAR TO pattern [ESCAPE char]</pre>
</div></div></li>
</ul>


<p>SIMILAR TO is a cross between LIKE and standard regular expression syntax.  % and _ are still used, rather than .&#42; and . respectively.</p>

<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/author/images/icons/emoticons/information.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>Note</b><br />Teiid does not exhaustively validate SIMILAR TO pattern values.  Rather the pattern is converted to an equivalent regular expression. Care should be taken not to rely on general regular expression features when using SIMILAR TO.  If additional features are needed, then LIKE_REGEX should be used. Usage of a non-literal pattern is discouraged as pushdown support is limited.</td></tr></table></div>

<ul>
        <li><div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">expression [NOT] LIKE_REGEX pattern</pre>
</div></div></li>
</ul>


<p>LIKE_REGEX allows for standard regular expression syntax to be used for matching.  This differs from SIMILAR TO and LIKE in that the escape character is no longer used (\ is already the standard escape mechanism in regular expressions and % and _ have no special meaning. The runtime engine uses the JRE implementation of regular expressions - see the <a href="http://download.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html" class="external-link" rel="nofollow">java.util.regex.Pattern</a> class for details.</p>

<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/author/images/icons/emoticons/information.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>Note</b><br />Teiid does not exhaustively validate LIKE_REGEX pattern values.  It is possible to use JRE only regular expression features that are not specified by the SQL specification.  Additional not all sources support the same regular expression flavor or extensions.  Care should be taken in pushdown situations to ensure that the pattern used will have same meaning in Teiid and across all applicable sources.</td></tr></table></div>

<ul>
        <li><div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">EXISTS (subquery)</pre>
</div></div></li>
</ul>


<ul>
        <li><div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">expression [NOT] BETWEEN minExpression AND maxExpression</pre>
</div></div></li>
</ul>


<p>Teiid converts BETWEEN into the equivalent form expression &gt;= minExpression AND expression &lt;= maxExpression</p>

<ul>
        <li><div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">expression</pre>
</div></div></li>
</ul>


<p>Where expression has type boolean.</p>

<p>Syntax Rules:</p>

<ul>
        <li>The precedence ordering from lowest to highest is comparison, NOT, AND, OR</li>
</ul>


<ul>
        <li>Criteria nested by parenthesis will be logically evaluated prior to evaluating the parent criteria.</li>
</ul>


<p>Some examples of valid criteria are:</p>

<ul>
        <li>(balance &gt; 2500.0)</li>
</ul>


<ul>
        <li>100*(50 - x)/(25 - y) &gt; z</li>
</ul>


<ul>
        <li>concat(areaCode,concat('-',phone)) LIKE '314%1'</li>
</ul>


<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/author/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>Comparing null Values</b><br />Null values represent an unknown value. Comparison with a null value will evaluate to 'unknown', which can never be true even if 'not' is used.</td></tr></table></div>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;" class="grey">
                        <a href="https://docs.jboss.org/author/users/removespacenotification.action?spaceKey=TEIID">Stop watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://docs.jboss.org/author/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
        <a href="https://docs.jboss.org/author/display/TEIID/Criteria">View Online</a>
        |
        <a href="https://docs.jboss.org/author/pages/diffpagesbyversion.action?pageId=18646219&revisedVersion=4&originalVersion=3">View Changes</a>
                |
        <a href="https://docs.jboss.org/author/display/TEIID/Criteria?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>