SQL Select Statement
The SELECT
statement is used to retrieve all the data of a table in a database.
Example
select * from employee;
This will retreive all the field values of the table employee.
Output
empno | name | age | role | location |
---|---|---|---|---|
001 | Andrew | 30 | Manager | India |
002 | Beslin | 28 | Business Analyst | India |
003 | Joanna | 23 | Senior Developer | USA |
To retrieve specific fields of the table specify the field name with comma seperation.
Example
select name,age from employee;
The above query will retrieve only the name and age fields of the employee table.
Output
name | age |
---|---|
Andrew | 30 |
Beslin | 28 |
Joanna | 23 |
If the select statement does not have any condition specified with where clause, then it will retrieve all the rows of the table.