SQLite - SPLessons

SQLite Expressions

Chapter 10

SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

SQLite Expressions

SQLite Expressions

shape Description

A sequence of single or extra esteems is said to be an expression. SQL functions and operators that appraise to a esteem. SQLite Expressions resemble equations and they are composed in queries dialect. And it can like-wisely utilize to inquiry the database for particular arrangement of information.

shape Syntax

Examine the fundamental syntax structure of the SELECT articulation:

Select column1,column2,….columnN from table_name where

[condition |expression];

Column =>The operation that  can be performed on the table.
Table_name => Name of the table that is created in the database.
Condition => Is a logical operation.
Expression =>A sequence of single or extra esteems.

Types of SQLite Expressions

shape Description

Expressions in SQLite can be classified into following stages. They are


Numeric Expressions

shape Description

To execute some scientific actions in queries, numerical expressions have to be used.

shape Syntax

Select numerical_expression as operation_name [From table_name where condition];
Numerical_Expression => Any mathematical expressions.

shape Examples

The following is an example for numeric expression.

 sqlite> select (20 + 4) as addition; 
24

The above example explains addition of two numbers.Such as a=20 and b=4 then it will choose those number and display the outputs.

Boolean Expressions

shape Description

The SQLite Expressions Boolean retrieve the information on the premise of coordinating individual esteems.

shape Syntax

Select column1,column2,…..columnN from table_name where single value matching expression;

Column => The operation that  can be performed on the table.
Table_name => Name of the table that is created in the database.
Expression => A sequence of single or extra esteems.

shape Examples

Here in the below example, showing an example of boolean expression.

sqlite> create table employee13(emp_id int,e_name varchar(20),salary int);
sqlite> insert into employee13 values(10,'jhon',10000);
sqlite> insert into employee13 values(20,'Mike',20000);
sqlite> insert into employee13 values(30,'Nike',30000);
sqlite> insert into employee13 values(40,'Maddie',40000);
sqlite> select * from employee13;
10|jhon|10000
20|Mike|20000
30|Nike|30000
40|Maddie|40000
sqlite> select * from employee13 where salary=20000;
20|Mike|20000

In the above example, the select statement will display all the employee details from the table name and by using Boolean expression. Defining where clause for one column and it will retrieve all the employee details from the employee table.

Date expression

shape Description

Date Expressions gives back the current framework time and date esteem and these expressions will be utilized as a part of different information controls.

shape Syntax

select current_timestamp;

shape Examples

Here in the below example, showing an example of date expression.

sqlite> select current_timestamp;
2016-06-01 10:00:02

The above example displays the current system date and time values.

Summary

shape Key Points

  • SQLite Expressions – A sequence of single or extra esteems.
  • Numeric expression – Executes some specific action in a query.
  • Boolean expression -Retrieves information from individual esteems.
  • Date expression – Shows the current system date and time values.