SQL SELECT Statement

In this tutorial, we will learn how to use the SELECT Statement in SQL Query with an example.

The SELECT QUERY is used to select data from the database table.

Syntax:

SELECT column1, column2, columnN FROM table_name;

In the above SELECT syntax, column1, column2,... are the name of those columns in the table whose data we want to fetch.

If you want to select all the fields available in the table, use the following syntax:

SELECT * FROM table_name;

Database Example

Consider the student table having the following records:−

Student_IDFirst_NameAddressAgeGrade
1AkashDelhi18A2
2BhaveshKanpur19A1
3YashDelhi20A2
4BhavnaDelhi19B1
5YatinLucknow20B1
6IshikaGhaziabad19C1
7VivekGoa20B2

Run Select Query with the above records.

SELECT * FROM `student`;

it will return all records of the student table.

If we required only Student_ID and First_Name from the above Student table. then our SQL Query will be.

SELECT Student_ID, First_Name  FROM `student`;

Output:

Student_IDFirst_Name
1Akash
2Bhavesh
3Yash
4Bhavna
5Yatin
6Ishika
7Vivek

Be First to Comment

Leave a Reply

Your email address will not be published.