SqliteAn expression
An expression is a combination of one or more values, operators, and SQL functions that evaluate values.
SQL expressions are similar to formulas and are written in the query language. You can also use a specific dataset to query the database.
Grammar
Suppose the basic syntax for a SELECT statement is as follows:
SELECT column1, column2,[| EXPRESSION];
There are different types of SQLite expressions, specifically explained below:
SQLite-Boolean expression
The Boolean expression of SQLite obtains data on the basis of matching a single value. The syntax is as follows:
SELECT column1, column2, COLUMNN from table_name WHERE single VALUE matchting EXPRESSION;
Suppose the company table has the following records:
ID NAME age ADDRESS SALARY---------- ---------- ---------- ---------- ---- ------1 Paul California 20000.02 Allen Texas 15000.03 Teddy at Norway 20000.04 Mark rich-mond 65000.05 David Texas 85000.06 Kim south-hall 45000.07 James Houston 10000.0
The following example demonstrates the use of a SQLite Boolean expression:
SQLite>*=10000; ID NAME Age ADDRESS SALARY--------------------------------------------------4 JamesHouston10000.0
SQLite-Numeric expression
These expressions are used to perform any mathematical operation in the query. The syntax is as follows:
As operation_name[fromtable_name WHERE CONDITION];
Here, Numerical_expression is used for mathematical expressions or any formula. The following example demonstrates the use of a SQLite numeric expression:
SQLite>(6 +)=
There are several built-in functions, such as AVG (), sum (), count (), and so on, that perform calculations called summary data for a table or a particular table column.
SQLite> Select COUNT(*)"RECORDS" from company; =7
SQLite-Date Expression
Date expressions return the current system date and time values, which are used for various data operations.
SQLite> SELECT current_timestamp; =-Geneva-- :
SQLite using Tutorial 11 expressions