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_ID | First_Name | Address | Age | Grade |
---|---|---|---|---|
1 | Akash | Delhi | 18 | A2 |
2 | Bhavesh | Kanpur | 19 | A1 |
3 | Yash | Delhi | 20 | A2 |
4 | Bhavna | Delhi | 19 | B1 |
5 | Yatin | Lucknow | 20 | B1 |
6 | Ishika | Ghaziabad | 19 | C1 |
7 | Vivek | Goa | 20 | B2 |
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_ID | First_Name |
---|---|
1 | Akash |
2 | Bhavesh |
3 | Yash |
4 | Bhavna |
5 | Yatin |
6 | Ishika |
7 | Vivek |
Be First to Comment