---
title: "Where Clause in SQL Statement"  
description: "Where clause is very important clause for filtering data .It search the records from the table according to the condition given in the where clause."  
author: "Manish Kumar"  
published: 2017-01-18  
updated: 2018-03-17  
canonical: https://www.mindstick.com/blog/11267/where-clause-in-sql-statement  
category: "database"  
tags: ["database", "sql"]  
reading_time: 2 minutes  

---

# Where Clause in SQL Statement

Where clause is very important clause for [filtering data](https://www.mindstick.com/forum/160900/how-to-use-searching-and-filtering-data-in-an-sql-server) .It [search](https://www.mindstick.com/blog/301883/why-you-shouldn-t-trust-ai-search-engines) the [records](https://www.mindstick.com/forum/34640/how-to-create-a-stored-procedure-for-display-all-records) from the table according to the [condition](https://www.mindstick.com/forum/12711/select-query-with-and-condition) given in the where clause.\

**We can use following [operator](https://www.mindstick.com/blog/144/union-intersection-and-except-operator-in-sql-server) in the where clause**

1- =

2- <

3- >

4- <=

5- >=

6- Between

7- Like

8- In

Suppose a table name Emp_Info and have following records

![Where Clause in SQL Statement](https://www.mindstick.com/blogs/03538b5f-08e2-47bd-9b7e-69ad53c51921/images/5df5ad49-456c-4505-a10d-f2cc853ab5fe.png)\

Now we take example of each operator on by one

```
select Emp_Name,Salary from Test.dbo.Emp_Info where salary=1000
```

output

![Where Clause in SQL Statement](https://www.mindstick.com/blogs/03538b5f-08e2-47bd-9b7e-69ad53c51921/images/d6905293-ee4f-4752-a2d2-9c0b529106d9.png)\

```
select Emp_Name,Salary from Test.dbo.Emp_Info where salary < 1500
```

## Output

\

![Where Clause in SQL Statement](https://www.mindstick.com/blogs/03538b5f-08e2-47bd-9b7e-69ad53c51921/images/06192a63-ff38-467e-9391-9c1bb6d969ce.png)\

select Emp_Name,Salary from Test.dbo.Emp_Info where salary > 1500

## output

\

![Where Clause in SQL Statement](https://www.mindstick.com/blogs/03538b5f-08e2-47bd-9b7e-69ad53c51921/images/41c009fb-7adf-48fa-9b21-423db7a8e651.png)\

[select](https://www.mindstick.com/forum/160534/orderby-then-select-vs-select-then-orderby-performance) Emp_Name,Salary from Test.dbo.Emp_Info where salary <= 1300

![Where Clause in SQL Statement](https://www.mindstick.com/blogs/03538b5f-08e2-47bd-9b7e-69ad53c51921/images/dfd66dde-42a8-4e5a-a184-4ca2d3a3420a.png)

\

select Emp_Name,Salary from Test.dbo.Emp_Info where salary >= 1600

\

![Where Clause in SQL Statement](https://www.mindstick.com/blogs/03538b5f-08e2-47bd-9b7e-69ad53c51921/images/7bdd1896-097c-4e0c-9249-f333f776e429.png)\

```
select Emp_Name,Salary from Test.dbo.Emp_Info where salary between 1000 and 1300
```

![Where Clause in SQL Statement](https://www.mindstick.com/blogs/03538b5f-08e2-47bd-9b7e-69ad53c51921/images/3078b1c4-a4a1-40bb-aae5-0275dec05393.png)

\

## Like Condition

\

Like condition is use for pattern matching and return result according to

\

the pattern.

1- % wildcard –it matches string of any length

\

2- _ wildcard- it matches single character

\

3- [] wildcard-it matches any character from the []

\

4- [^] wildcard-it not matches the character that is in[^]

Suppost we have Employee table and have following records

\

![Where Clause in SQL Statement](https://www.mindstick.com/blogs/03538b5f-08e2-47bd-9b7e-69ad53c51921/images/306ed7f8-73bb-4382-b7f6-f2b15a01df72.png)\

```
select * from Test.dbo.Employee where Name   Like '%h';
```

\

![Where Clause in SQL Statement](https://www.mindstick.com/blogs/03538b5f-08e2-47bd-9b7e-69ad53c51921/images/87e66e4f-7303-4b14-b60e-28477c0e40e3.png)\

In-It return all the records between two condition .it allows multiple values in where clause.

```
select * from Test.dbo.Emp_Info where salary IN (1000,1200)     
```

\

![Where Clause in SQL Statement](https://www.mindstick.com/blogs/03538b5f-08e2-47bd-9b7e-69ad53c51921/images/ccd9a40a-4a89-413c-b972-6bb96f04c55b.png)\

You can also visit these related [articles](https://www.mindstick.com/articles/12872/how-to-write-articles-of-50-and-more-a-day-quick-and-easy) & blogs

[SQLite Where clause](https://www.mindstick.com/Articles/1870/sqlite-where-clause)

[What is the difference between a HAVING CLAUSE and a WHERE CLAUSE](https://www.mindstick.com/Interview/1871/what-is-the-difference-between-a-having-clause-and-a-where-clause)

---

Original Source: https://www.mindstick.com/blog/11267/where-clause-in-sql-statement

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
