SQL - SPLessons

SQL Select

Chapter 13

SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

SQL Select

SQL Select

shape Description

The SELECT proclamation is utilized to retrieve the information from the database. SQL Select statement writes the query and returns the result as a result set. In select statement the Where Clause clause will work like below:

shape Conceptual

shape Syntax

The syntax for SQL Select statement is as follows:
SELECT[ALL|DISTINCT] column1, column2…..FROM <table_name>,….. WHERE <search_condition>;

WHERE => Used to mention a search condition to obtain the desired result set and limits the number of rows.

ALL or DISTINCT => For retrieving all record and eliminate duplicate records respectively.


shape Type-1

To fetch all the record from table department, use following query:

sql> create table department(dept_id int,dname varchar(255),commission int)
Query ok, 0 rows affected (0.64 sec)

sql> insert into department values(1001,'Oracle',12000);
Query OK, 1 row affected (0.10 sec)

sql> insert into department values(1002,'Mysql',Null);
Query OK, 1 row affected (0.39 sec)

sql> select * from department;
| dept_id | dname  | commission |
|   1001  | Oracle |   12000    |
|   1002  | Mysql  |   Null     |
2 rows in set (0.00 sec)

sql>SELECT * FROM department WHERE commission='Null';

| dept_id | dname  | commission |
|   1002  | Mysql  |   Null     |
1 rows in set (0.00 sec)

Here in the above example,select statement is used to retrieve all the field values from the database table department.


shape Key Points

  • SQL Select proclamation – Select proclamation is utilized to recover the records from the database.