SQLite Forum

operator precedence docs missing, suggested clarifications below
Login
This is probably the last take, unless a compelling argument shows it should not be:

=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*

<h1 id="operators_and_parse_affecting_attributes"><span>2. </span>Operators, and Parse-Affecting Attributes</h1>
SQLite understands these operators, listed
 in precedence<sup>1</sup> order (highest to lowest):
<p></p>

<table width="50%" border="1" border-collapse="collapse" line-height="1.2">
  <tr align="center">
    <td text-align="center"><b>Operators <sup>2</sup> <sup>3</sup></b></td>
  </tr>
  <tr align="center">
    <td>~&nbsp;&lsqb;expr&rsqb;&nbsp;&nbsp;&nbsp;&nbsp;+&nbsp;&lsqb;expr&rsqb;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&lsqb;expr&rsqb;</td>
  </tr>
  <tr align="center">
    <td>&lsqb;expr&rsqb;&nbsp;COLLATE&nbsp;(collation-name) <sup>3</sup></td>
  </tr>
  <tr align="center">
    <td>||</td>
  </tr>
  <tr align="center">
    <td>*&nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;&nbsp;%</td>
  </tr>
  <tr align="center">
    <td>+&nbsp;&nbsp;&nbsp;-</td>
  </tr>
  <tr align="center">
    <td>&amp;&ensp;&nbsp;|&nbsp;&nbsp;&nbsp;&lt;&lt;&ensp;&nbsp;&gt;&gt;</td>
  </tr>
  <tr align="center">
    <td>ESCAPE&nbsp;&lsqb;expr&rsqb; <sup>4</sup></td>
  </tr>
  <tr align="center">
    <td>&lt;&nbsp;&nbsp;&gt;&nbsp;&nbsp;&lt;=&nbsp;&nbsp;&gt;=</td>
  </tr>
  <tr align="center">
    <td>=&nbsp;&nbsp;==&nbsp;&nbsp;&lt;&gt;&nbsp;&nbsp;!=&nbsp;&nbsp;IS&nbsp;&nbsp;&nbsp;IS&nbsp;NOT<br>
      &lsqb;expr&rsqb;&nbsp;BETWEEN<sup>5</sup>&nbsp;&lsqb;expr&rsqb;&nbsp;AND&nbsp;&lsqb;expr&rsqb;<sup>&ensp;</sup><br>
      IN<sup>5</sup>&nbsp;&nbsp;MATCH<sup>5</sup>&nbsp;&nbsp;LIKE<sup>5</sup>&nbsp;&nbsp;REGEXP<sup>5</sup>&nbsp;&nbsp;GLOB<sup>5</sup><br>
      &lsqb;expr&rsqb;&nbsp;ISNULL&nbsp;&nbsp;&lsqb;expr&rsqb;&nbsp;NOTNULL&nbsp;&nbsp;&nbsp;&lsqb;expr&rsqb;&nbsp;NOT&nbsp;NULL
    </td>
  </tr>
  <tr align="center">
    <td>NOT&nbsp;&lsqb;expr&rsqb;</td>
  </tr>
  <tr align="center">
    <td>AND</td>
  </tr>
  <tr align="center">
    <td>OR</td>
  </tr>
</table>
<p>
<b>1.</b> Operators shown within the same table cell share precedence.<br>
<b>2.</b> "&lsqb;expr&rsqb;" denotes operand locations for non-binary operators.<br>
 &nbsp;&nbsp;Operators with no "&lsqb;expr&rsqb;" adjunct are binary and left associative. <br>
<b>3.</b> The COLLATE clause (with its collation-name) acts as a single postfix operator.<br>
<b>4.</b> The ESCAPE clause (with its escape character) acts as a single postfix operator.<br>
 &nbsp;&nbsp;It can only bind to a preceding &lsqb;expr&rsqb; LIKE &lsqb;expr&rsqb; expression.<br>
<b>5.</b> Each keyword in (BETWEEN IN GLOB LIKE MATCH REGEXP) may be prefixed<br>
 &nbsp;&nbsp;by NOT, retaining the bare operator's precedence and associativity.
</p>