The Select statement in SQL is the most commonly query used statement in SQL. It is used to either fetch a data according to some specified rule or display an entire table. The data displayed after the query execution is stored in a result table.
Watch this Select Statement in SQL video
In this tutorial section, we will discuss on:
The Select query in SQL is one of the most important commands in SQL, and it is used to get data from a table.
SELECT column1, column2, columnN FROM tablename;
where SELECT and FROM are the keywords; column1 to columnN are a set of columns, and tablename is the name of the table followed by a semicolon.
Select e_name From employee; (single column) Select e_name, e_age From employee;
The Select option contains the table name and the From option contains the table name from where we want to fetch the data.
Select * from employee;
A column often contains many duplicate values, and sometimes the information needed from a single column has to be distinct. Using the SELECT DISTINCT statement, we can filter out distinct values from a column.
SELECT DISTINCT column1, column2, columnN FROM tablename;
where SELECT DISTINCT and FROM are the keywords, column1 to columnN are a set of columns, and tablename is the name of the table, followed by a semicolon.
select distinct e_gender from employee;
Let’s remove the distinct keyword and run the query.
select e_gender from employee;
When the distinct keyword was removed, all values got displayed., which gives us a clear picture of the Select Distinct statement; it gets only the values which are different.
This bring us to the end of this Select Query in SQL. Here, we learned to use Select Command in SQL and Select Distinct command in SQL .Previous Next
Download Interview Questions asked by top MNCs in 2019?