blog

Home / DeveloperSection / Blogs / Where Clause in SQL Statement

Where Clause in SQL Statement

Manish Kumar2807 18-Jan-2017

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.

We can use following operator 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

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

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

 

Output


Where Clause in SQL Statement

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

 

output


Where Clause in SQL Statement

select Emp_Name,Salary from Test.dbo.Emp_Info where salary <= 1300

 Where Clause in SQL Statement


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


Where Clause in SQL Statement

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

 Where Clause in SQL Statement


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

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


Where Clause in SQL Statement

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

You can also visit these related articles & blogs

SQLite Where clause

What is the difference between a HAVING CLAUSE and a WHERE CLAUSE


Updated 17-Mar-2018

Leave Comment

Comments

Liked By