WHERE Condition is used for filter records
WHERE Condition is used to filter records that match in specified WHERE condition
WHERE Syntax
SELECT C1, C2 FROM YourTableName WHERE YourCondition
Example
1. SELECT * FROM City WHERE CityName = 'Test'
2. SELECT * FROM Country WHERE CountryID = 1
Operators Use in Where Condition
1. = Equal Record match
2. <> or != Not Equal Record match
3. > Grater than record match
4. < Less than record match
5. >= Grater than and equal to record match
6. <= Less than and equal to record match
7. BETWEEN record filter between range
8. LIKE filter with pattern LIKE Operator condition use like %
9. IN filter all possible record in table
Example of operator wise
1. SELECT * FROM Country WHERE Name = 'India'
2. SELECT * FROM Country WHERE ID <> 1 or SELECT * FROM Country WHERE ID != 1
3. SELECT * FROM Employee WHERE Salary < 10000
4. SELECT * FROM Employee WHERE Salary > 10000
5. SELECT * FROM Employee WHERE Salary <= 10000
6. SELECT * FROM Employee WHERE Salary >= 10000
7. SELECT * FROM Employee WHERE Salary BETWEEN 5000 AND 10000
8. SELECT * FROM Employee WHERE EmployeeName LIKE '%A' end with A
9. SELECT * FROM Employee WHERE EmployeeName LIKE 'A%' start with A
10. SELECT * FROM Employee WHERE EmployeeName LIKE '%A%' start with A or end with A
11. SELECT * FROM Employee WHERE EmployeeName IN ('A', 'B', 'C')
WHERE Condition is used to filter records that match in specified WHERE condition
WHERE Syntax
SELECT C1, C2 FROM YourTableName WHERE YourCondition
Example
1. SELECT * FROM City WHERE CityName = 'Test'
2. SELECT * FROM Country WHERE CountryID = 1
Operators Use in Where Condition
1. = Equal Record match
2. <> or != Not Equal Record match
3. > Grater than record match
4. < Less than record match
5. >= Grater than and equal to record match
6. <= Less than and equal to record match
7. BETWEEN record filter between range
8. LIKE filter with pattern LIKE Operator condition use like %
9. IN filter all possible record in table
Example of operator wise
1. SELECT * FROM Country WHERE Name = 'India'
2. SELECT * FROM Country WHERE ID <> 1 or SELECT * FROM Country WHERE ID != 1
3. SELECT * FROM Employee WHERE Salary < 10000
4. SELECT * FROM Employee WHERE Salary > 10000
5. SELECT * FROM Employee WHERE Salary <= 10000
6. SELECT * FROM Employee WHERE Salary >= 10000
7. SELECT * FROM Employee WHERE Salary BETWEEN 5000 AND 10000
8. SELECT * FROM Employee WHERE EmployeeName LIKE '%A' end with A
9. SELECT * FROM Employee WHERE EmployeeName LIKE 'A%' start with A
10. SELECT * FROM Employee WHERE EmployeeName LIKE '%A%' start with A or end with A
11. SELECT * FROM Employee WHERE EmployeeName IN ('A', 'B', 'C')
No comments:
Post a Comment