SQL - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

SQL Expressions

SQL Expressions

shape Description

Sequence of single or extra esteems are said to be SQL Expressions. SQL functions and operators appraise to a esteem. SQL Expressions resemble equations and 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 Expressions

shape Description

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

shape Conceptual figure

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. [c] sql> select (20 + 4) as addition; 24[/c] The above example explains addition of two numbers such as a=20 and b=4, then it will choose those numbers and display the outputs.

Boolean Expressions

shape Description

The SQL 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. [c]sql> select * from employee21; +--------+-------+-------+ | emp_id | ename | sal | +--------+-------+-------+ | 1001 | mike | 12000 | | 1002 | rambo | 13000 | +--------+-------+-------+ 2 rows in set (0.00 sec) sql> select * from employee21 where sal=13000; +--------+-------+-------+ | emp_id | ename | sal | +--------+-------+-------+ | 1002 | rambo | 13000 | +--------+-------+-------+ 1 row in set (0.00 sec) [/c] 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. [c]sql> select current_timestamp; 2016-06-01 10:00:02[/c] The above example displays the current system date and time values.

Summary

shape Key Points

  • SQL 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.