Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Select statement in MS SQL Server

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

In this article, the most basic statement used in SQL is being discussed.

Basic statement: select

  1. There are large amounts of data available everywhere.
  2. The data is stored in a sequential order in form of a table.
  3. Each table consists of a row which represents a unique record and column represents a field.
  4. Schemas are used to arrange the tables in a logical order.
  5. In order to extract particular data from the tables, queries are being used which is written in Structured Query Language(SQL).
  6. To query data, select statement is used.

Syntax:

select 
select_list;
from
schema_name.table.name; 

In order to retrieve all the columns from a table, select* is being used.

Syntax -
select*
from
table_name; 

Points to remember:

  1. In the real time databases, select* isn’t recommended for use because it retrieves the data more than your requirements.
  2. It results in slow functioning of the application.
  3. In case, the user adds more columns to the table, the select* statement retrieves all the columns including the new ones resulting in crashing of the application.

Example:

Roll numberNameCourse
111RiyaCSE
112ApoorvaECE
113MinaMech
114RitaBiotechnology
115VeenaChemical
116DeepaEEE

If the user wants to retrieve the name of the student pursuing Computer Science, the query is as follows:

select 
name 
from
course.student
where course='cse' 

Note that course is the name of the schema and student is the name of the table.

The output will be retrieved as follows:

NameCourse
RiyaCSE

Note –
To retrieve the query, another statement where is being used which will be discussed in further articles.

My Personal Notes arrow_drop_up
Last Updated : 04 Jun, 2020
Like Article
Save Article
Similar Reads