lang_expr.html
来自「sqlite 3.3.8 支持加密的版本」· HTML 代码 · 共 267 行 · 第 1/2 页
HTML
267 行
</tr>
<tr>
<td align="right" width="1%" nowrap>
<i><font color="#ff3434">like-op</font></i> ::=</td>
<td>
<b><font color="#2c2cf0">LIKE </font></b><big>|</big><b><font color="#2c2cf0"> GLOB
</font></b><big>|</big><b><font color="#2c2cf0"> REGEXP </font></b><big>|</big><b><font
color="#2c2cf0"> MATCH</font></b></td>
</tr>
</table>
</p>
<p>
This section is different from the others. Most other sections of this document
talks about a particular SQL command. This section does not talk about a standalone
command but about "expressions" which are subcomponents of most other commands.</p>
<p>
SQLite understands the following binary operators, in order from highest to lowest
precedence:</p>
<blockquote>
<pre><font color="#2c2cf0"><big>|| * / % + - << >> & | < <= >
>= = == != <> </big>IN AND OR</font>
</pre>
</blockquote>
<p>
Supported unary operators are these:</p>
<blockquote>
<pre><font color="#2c2cf0"><big>- + ! ~ NOT</big></font>
</pre>
</blockquote>
<p>
The unary operator [Operator +] is a no-op. It can be applied to strings, numbers,
or blobs and it always gives as its result the value of the operand.</p>
<p>
Note that there are two variations of the equals and not equals operators. Equals
can be either <font color="#2c2cf0"><big>=</big></font> or <font color="#2c2cf0"><big>
==</big></font>. The non-equals operator can be either <font color="#2c2cf0"><big>
!=</big></font> or <font color="#2c2cf0"><big><></big></font>. The <font color="#2c2cf0">
<big>||</big></font> operator is "concatenate" - it joins together the two
strings of its operands. The operator <font color="#2c2cf0"><big>%</big></font>
outputs the remainder of its left operand modulo its right operand.</p>
<p>
The result of any binary operator is a numeric value, except for the <font color="#2c2cf0">
<big>||</big></font> concatenation operator which gives a string result.</p>
<a name="literal_value"></a>
<p>
A literal value is an integer number or a floating point number. Scientific notation
is supported. The "." character is always used as the decimal point even if the
locale setting specifies "," for this role - the use of "," for the decimal point
would result in syntactic ambiguity. A string constant is formed by enclosing the
string in single quotes ('). A single quote within the string can be encoded by
putting two single quotes in a row - as in Pascal. C-style escapes using the backslash
character are not supported because they are not standard SQL. BLOB literals are
string literals containing hexadecimal data and preceded by a single "x" or "X"
character. For example:</p>
<blockquote>
<pre>X'53514697465'
</pre>
</blockquote>
<p>
A literal value can also be the token "NULL".
</p>
<p>
A parameter specifies a placeholder in the expression for a literal value that is
filled in at runtime using the <a href="capi3ref.html#sqlite3_bind_int">sqlite3_bind</a>
API. Parameters can take several forms:
</p>
<p>
<table>
<tr>
<td align="right" width="1%" nowrap>
<b>?</b><i>NNN</i></td>
<td width="20">
</td>
<td>
A question mark followed by a number <i>NNN</i> holds a spot for the NNN-th parameter.
NNN must be between 1 and 999.</td>
</tr>
<tr>
<td align="right" width="1%" nowrap>
<b>?</b></td>
<td width="20">
</td>
<td>
A question mark that is not followed by a number holds a spot for the next unused
parameter.</td>
</tr>
<tr>
<td align="right" width="1%" nowrap>
<b>:</b><i>AAAA</i></td>
<td width="20">
</td>
<td>
A colon followed by an identifier name holds a spot for a named parameter with the
name AAAA. Named parameters are also numbered. The number assigned is the next unused
number. To avoid confusion, it is best to avoid mixing named and numbered parameters.</td>
</tr>
<tr>
<td align="right" width="1%" nowrap>
<b>@</b><i>AAAA</i></td>
<td width="20">
</td>
<td>
An "at" sign works exactly like a colon.</td>
</tr>
<tr>
<td align="right" width="1%" nowrap>
<b>$</b><i>AAAA</i></td>
<td width="20">
</td>
<td>
A dollar-sign followed by an identifier name also holds a spot for a named parameter
with the name AAAA. The identifier name in this case can include one or more occurances
of "::" and a suffix enclosed in "(...)" containing any text at all. This syntax
is the form of a variable name in the Tcl programming language.</td>
</tr>
</table>
</p>
<blockquote>
</blockquote>
<p>
Parameters that are not assigned values using <a href="capi3ref.html#sqlite3_bind_int">
sqlite3_bind</a> are treated as NULL.</p>
<a name="like"></a>
<p>
The LIKE operator does a pattern matching comparison. The operand to the right contains
the pattern, the left hand operand contains the string to match against the pattern.
A percent symbol <font color="#2c2cf0"><big>%</big></font> in the pattern matches
any sequence of zero or more characters in the string. An underscore <font color="#2c2cf0">
<big>_</big></font> in the pattern matches any single character in the string.
Any other character matches itself or it's lower/upper case equivalent (i.e. case-insensitive
matching). (A bug: SQLite only understands upper/lower case for 7-bit Latin characters.
Hence the LIKE operator is case sensitive for 8-bit iso8859 characters or UTF-8
characters. For example, the expression <b>'a' LIKE 'A'</b> is TRUE but <b>'
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?