bing
Flat 10% & upto 50% off + 10% Cashback + Free additional Courses. Hurry up
×
UPTO
50%
OFF!
Intellipaat
Intellipaat

Select Statement in SQL

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:

A Brief on the Select Query in SQL

The Select query in SQL is one of the most important commands in SQL, and it is used to get data from a table.

Syntax

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.

How to Select Data from a Table?

  • Let’s display the name and age of an employee from the employee table
Select e_name From employee; (single column)

Select e_name, e_age From employee;

How to Select Data from a Table

  • After writing the query, click on the execute button to check for errors
  • Once the query is executed, the table appears

The Select option contains the table name and the From option contains the table name from where we want to fetch the data.

  • To select everything from a table, use * (asterisk operator)
Select * from employee;

How to Select Data from a Table 2

  • After writing the query, click on the execute button to check for errors
  • Once the query is executed, the table appears

Select Distinct in SQL

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.

Syntax

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.

How to Select Distinct Data from a Table?

  • Let’s select some distinct values from our employee table. If we have a glance at the gender column, we can see that two values are being repeated, male and female.
select distinct e_gender from employee;

How to Select Distinct Data from a Table

  • After writing the query, click on the execute button to check for errors
  • Once the query is executed, the table appears

Let’s remove the distinct keyword and run the query.

select e_gender from employee;

How to Select Distinct Data from a Table 2

  • After writing the query, click on the execute button to check for errors
  • Once the query is executed, the table appears

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?

"0 Responses on Select Query in SQL"

    100% Secure Payments. All major credit & debit cards accepted Or Pay by Paypal.
    top

    Sales Offer

    Sign Up or Login to view the Free Select Query in SQL.