SQL Select Command
Select command is used to retrieved the data from the existing table in the database.
- Using Select command you can retrieve all the records from the table in the database.
- Using Select command you can retrieve specific records from the table "using where clause"
Syntax
select * from table_name;
Note: In the above syntax * represent all columns.
Example
select * from Employee;
Employee table
Using this table i will show you how to select employee record whose salary is greater than 30000.
| emp_id | name | salary |
|---|---|---|
| 101 | Amit | 24000 |
| 102 | Gaurav | 26000 |
| 103 | Hitesh | 35000 |
| 104 | Rahul | 34000 |
| 103 | Sultan | 54000 |
Example
SELECT emp_id, name FROM Employee
Result after using Select Command
| emp_id | name |
|---|---|
| 101 | Amit |
| 102 | Gaurav |
| 103 | Hitesh |
| 104 | Rahul |
| 103 | Sultan |
Select command with where clause
When you need to select some specific record from table you can use where clause with select command, in below example i will select those employee records who have more than 30000 salary.
Example
SELECT * from Employee WHERE salary>30000;
Result after using Execute above query.
| emp_id | name | salary |
|---|---|---|
| 105 | Hitesh | 35000 |
| 102 | Rahul | 34000 |
| 103 | Sultan | 54000 |
Comments
Post a Comment