SELECT Keyword
You can choose data from a database using the SELECT command. The information returned is kept in a result table known as the result set.
Syntax
SELECT <COLUMN_NAME1>, <COLUMN_NAME2>, <COLUMN_NAME_N> FROM <TABLE_NAME>;
OR
SELECT * FROM <TABLE_NAME>;
Example
SELECT Emp_id,Emp_Name,Emp_Gender From Employee
OR
SELECT * FROM Employee
SELECT DISTINCT
The SELECT DISTINCT statement is used for returning only distinct (different) values from a column.
Syntax
SELECT DISTINCT <COLUMNS> FROM <TABLE_NAME>;
Example 1
SELECT DISTINCT * FROM Employee;
In the above example, only the different/distinct row will be displayed.
Example 2
SELECT DISTINCT Emp_Name FROM Employee;
In above example only different names will be displayed.
SELECT TOP
The SELECT TOP is used to specify the number of rows to return.
Syntax
SELECT TOP <VALUE> * FROM <TABLE_NAME>
Example
SELECT TOP 5 * FROM Employee
In the above example, a query will return the first 5 records from the employee table.
SELECT INTO
The SELECT INTO statement is used to copy data from one table and insert it into a new table.
Syntax
SELECT <COLUMN_NAME1>, <COLUMN_NAME2>, <COLUMN_NAME_N> INTO <NEW_TABLE> FROM <MAIN_TABLE>;
OR
SELECT * INTO <NEW_TABLE> FROM <MAIN_TABLE>;
Example
SELECT Emp_id,Emp_Name,Emp_Gender INTO Emp_New FROM Employee;
OR
SELECT * INTO Emp_New FROM Employee;
Summary
The SELECT command is used to select data from a database.