SQL Select Statement

Select statement is used to retrieve the records from the table

If you need all records from the table

Syntax:-



SELECT * FROM table_name

Example 1:- Suppose we have employees table and we want all records from the employees table



SELECT * FROM employees

Output:-


+----+------------+-----------+----------------+------------+
| id | first_name | last_name | email          | address    |
+----+------------+-----------+----------------+------------+
|  1 | John       | Tailor    | john@abc.com   | California |
|  2 | Rom        | Tailor    | rom@abc.com    | California |
|  3 | Andrew     | Symonds   | andrew@abc.com | Sydney     |
|  4 | Miacle     | clerk     | miacle@abc.com | sydney     |
|  5 | Sachin     | Tendulkar | sachin@abc.com | Mumbai     |

Example 2:- Suppose we want to get specific records like id,first_name,email from employees table



SELECT id,first_name,email FROM employees

Output:-



+----+------------+----------------+
| id | first_name | email          |
+----+------------+----------------+
|  1 | John       | john@abc.com   |
|  2 | Rom        | rom@abc.com    |
|  3 | Andrew     | andrew@abc.com |
|  4 | Miacle     | miacle@abc.com |
|  5 | Sachin     | sachin@abc.com |
+----+------------+----------------+
5 rows in set (0.00 sec)