Where clause in MS SQL Server

In this article, where clause will be discussed alongside example.

Introduction :

  1. To extract the data at times, we need a particular conditions to satisfy.
  2. ‘where’ is a clause used to write the condition in the query.

Syntax :

select select_list
from table_name
where condition

A example is given below for better clarification –

Example :

Sample table: Student

Roll number Name Course
111 Riya CSE
112 Apoorva ECE
113 Mina Mech
114 Rita Biotechnology
115 Veena Chemical
116 Deepa EEE

If a user wants to extract the name of the student who is pursuing Mechanical, the query is as follows:

select name
from student
where course='Mechanical' 

The output is –

Name Course
Mina Mech

‘where’ condition filters only the rows that are evaluated to true. If the condition evaluates to false or unknown, the rows will not be filtered causing an error.

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.