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
Now we take example of each operator on by one
select Emp_Name,Salary from Test.dbo.Emp_Info where salary=1000
output
select Emp_Name,Salary from Test.dbo.Emp_Info where salary < 1500
Output
select Emp_Name,Salary from Test.dbo.Emp_Info where salary > 1500
output
select Emp_Name,Salary from Test.dbo.Emp_Info where salary <= 1300
select Emp_Name,Salary from Test.dbo.Emp_Info where salary >= 1600
select Emp_Name,Salary from Test.dbo.Emp_Info where salary between 1000 and 1300
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
select * from Test.dbo.Employee where Name Like '%h';
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)
You can also visit these related articles & blogs
What is the difference between a HAVING CLAUSE and a WHERE CLAUSE
Leave Comment