Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
6Activity
0 of .
Results for:
No results containing your search query
P. 1
SQLite Expressions

SQLite Expressions

Ratings: (0)|Views: 411 |Likes:
Published by pun_82b

More info:

Published by: pun_82b on Jun 25, 2010
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

08/23/2010

pdf

text

original

 
SQLite expressions
In this part of the SQLite tutorial, we will cover SQLite expressions.An expression in a programming language is a combination of values, variables, operators, andfunctions that are interpreted (evaluated) according to the particular rules of precedence and of association for a particular programming language, which computes and then produces (returns, in astateful environment) another value. The expression is said to evaluate to that value. (wikipedia)
Literal values
A literal value is a constant of some kind. Literal values may be integers, floating point numbers,strings, BLOBs, or NULLs.
sqlite> SELECT 3, 'Wolf', 34.5;3|Wolf|34.5
Here we return three literals. Namely integer, string and floating point constants.
sqlite> .nullvalue NULLsqlite> SELECT NULL;NULL
 The
.nullvalue
command tells the SQLite to show
NULL
values as
NULL
. SQLite shows empty stringsfor
NULL
values by default.
NULL
value is a literal too.
sqlite> SELECT x'345eda2348587aeb';
 
4^�#HXz
BLOB
literals are string literals containing hexadecimal data and preceded by a single "x" or "X"character.
Operators
Operators
are used to build expressions. SQL operators are very similar to mathematical operators. There are two kinds of operators. Binary and unary. Binary operators work with two operands, unarywork with one. An operator may have one or two operands. An
operand
is one of the inputs(arguments) of an operator.We have several types of operators:
Arithmetic operators
Boolean operators
Relational operators
Bitwise operators
Other operatorsSQLite understand the following binary operators.
||* / %+ -<< <> & |< <= > >== == != <> IS IN LIKE GLOB BETWEEN
 
ANDOR
Operators are arranged according to the precedence. The
||
operator has the highest order of precedence, the
OR
operator the lowest. These are the unary prefix operators:
- + ~ NOT
 The
+
is a no-op. It does not do anything. The
-
unary operator changes positive values to negative andvice versa.
sqlite> SELECT -(3-44);41
 The result is 41. The other two operators will be discussed later on.
Arithmetic operators
Arithmetic operators understood by SQLite are: multiplication, division, addition, subtraction andmodulo.
sqlite> SELECT 3*3/9;1
 These are multiplication and division operators, that we know from mathematics.
sqlite> SELECT 3 + 4 - 1 + 5;11

Activity (6)

You've already reviewed this. Edit your review.
1 thousand reads
1 hundred reads
carbonmetrics liked this
Shahid Tamboli liked this
Rohan Chatterjee liked this
Decebal Dobrica liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->