What is a select Statement ?
Answer : The SQL SELECT statement is used to fetch data from a database table.
Example :
We have a Employees table:
| Employee_ID | Employee_Name | Salary |
|---|---|---|
| 101 | Anjali | 5000 |
| 102 | Priya | 4000 |
| 103 | Amit | 6000 |
if you want to select all the fields from the table, use the following syntax:
Syntax : Select * from table_name;
Select * from Employees;
Return :
| Employee_ID | Employee_Name | Salary |
|---|---|---|
| 101 | Anjali | 5000 |
| 102 | Priya | 4000 |
| 103 | Amit | 6000 |
To retrieve only specific columns:
Syntax : Select column1, column2….. from table_name;
Here column1 , column2… are the fields of a table whose values you want to fetch.
Select Employees_Name, Salary from Employees;
Return :
| Employee_Name | Salary |
|---|---|
| Anjali | 5000 |
| Priya | 4000 |
| Amit | 6000 |