Home » SQL

SQL - SELECT Command (to retrieve data from table/view)

Learn: How to get/fetch selected columns, rows of all columns, row of a table/view using SELECT query?
Submitted by Shubham Singh Rajawat, on September 17, 2017

SELECT command/query is used to fetch data from the database/table. We can either fetch some columns or fetch an entire table. As select is a query that means it returns some data which is actually got stored in another table called result-set.

Syntax:

SELECT column1, column2,... FROM table_name;

Here,
column1, column2,... are the name of the fields in the table.
table_name is the name of the table from which we want to fetch data.

select command in sql

Queries

1. Query to fetch an entire table

SELECT * FROM Student;

We can also write all field names instead of "*" but that would be quite tedious to write all of the field names

select query in sql

2. Query to fetch Enroll_No, Student_name, DOB, City

SELECT Enroll_No, Student_name, DOB,City FROM Student;

This will return a result-set with fields Enroll_No, Student_name, DOB, City and their data from Student

select statement in sql



Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.