WHERE Clause in SQL Server

WHERE Clause is used to conditinally filter the result set in SQL Server.

WHERE Clause is used along with SELECT Command to restrict the data.

Syntax for WHERE Clause is :

  • WHERE  < Condition>
  • WHERE  <Column that has be to compared> <Operator> <Value with which comparision has to be done>

Example:

I have a table with the name MYORDERS which holds Orders information in it.

Lets say we need information related to the OrderId= 100002, Then this information can be retrieved by using the following command:

SELECT * FROM MYORDERS WHERE OrderId= 100002









Above example uses = (equals to) operators in the WHERE Clause.

We can use other operators also in WHERE Clasue. Here is the list of all operators that can be used in WHERE Clause:
  • =
  • >
  • <
  • >=
  • <=
  • !=
  • IN
  • NOT IN
  • LIKE
  • IS NULL
  • IS NOT NULL

This entry was posted in . Bookmark the permalink.

Leave a reply