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.


SELECT column1, column2,... FROM table_name;

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


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



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.