See the expressions page of the SQLite3 documentation for much more information.
C/Java vs SQL
Many C/Java operators work with SQL; however, there are some notable exceptions. Here are some things to watch out for.
- Booleans operators need to be spelled out, e.g.,
AND,OR, andNOT - The
||operator concatentates two strings - Use
<>to test if two expressions are not equal - The single equal sign,
=, can also be used to test for equality - Generally when one of the operands is
NULL, the result will beNULL - However, the operators
ISandIS NOTcan test for equality even withNULLoperands.
String matching
SQL uses the LIKE operator for string matches.
In this case the % matches zero or more characters
and the _ matches one character
By default, the string matching operator is not
case sensative.
For example, 'SQL' LIKE 'S%'
and 'SQL' LIKE 'S_L'
and 'SQL' LIKE 'sql'
are all true.
Many SQL implementations support regular expression matches
with a REGEXP or ~ operator.
Table operators
SQL has a few set operators for testing a value against the
result of a table returned from a SELECT.
EXISTSis a unary operator that tests if the returned table has any elementsINandNOT INare binary operators that test for membership in the returned table
-
aggregate functions
modified comparisons