The SQL SELECT statement is used to fetch the data from a database table which returns this data in the form of a result table. These result tables are called result-sets.
SQL SELECT Statement
The SELECT statement is the most commonly used command in Structured Query Language. It is used to access the records from one or more database tables and views. It also retrieves the selected data that follow the conditions we want.
By using this command, we can also access the particular record from the particular column of the table. The table which stores the record returned by the SELECT statement is called a result-set table.
OR
The SQL SELECT statement is used to fetch the data from a database table which returns this data in the form of a result table. These result tables are called result-sets.
Syntax of SELECT Statement in SQL
SELECT Column_Name_1, Column_Name_2, ....., Column_Name_N FROM Table_Name;
SELECT * FROM table_name;
Examples of SELECT Statement in SQL
CREATE TABLE Student_Records ( Student_Id Int PRIMARY KEY, First_Name VARCHAR (20), Address VARCHAR (20), Age Int NOT NULL, Percentage Int NOT NULL, Grade VARCHAR (10) ) ;
INSERT INTO Student VALUES (201, Akash, Delhi, 18, 89, A2), (202, Bhavesh, Kanpur, 19, 93, A1), (203, Yash, Delhi, 20, 89, A2), (204, Bhavna, Delhi, 19, 78, B1), (05, Yatin, Lucknow, 20, 75, B1), (206, Ishika, Ghaziabad, 19, 51, C1), (207, Vivek, Goa, 20, 62, B2);
SELECT * FROM table_name;
Student_ID | First_Name | Address | Age | Percentage | Grade |
---|---|---|---|---|---|
201 | Akash | Delhi | 18 | 89 | A2 |
202 | Bhavesh | Kanpur | 19 | 93 | A1 |
203 | Yash | Delhi | 20 | 89 | A2 |
204 | Bhavna | Delhi | 19 | 78 | B1 |
205 | Yatin | Lucknow | 20 | 75 | B1 |
206 | Ishika | Ghaziabad | 19 | 91 | C1 |
207 | Vivek | Goa | 20 | 80 | B2 |
0 Comments