🔍 Lab 2.2 : AND, OR, IN, BETWEEN, LIKE, IS NULL

🔍 Lab 2.2: SQL Filtering — AND, OR, IN, BETWEEN, LIKE, IS NULL

In this lab, you will learn how to filter data in SQL using advanced condition operators: AND, OR, IN, BETWEEN, LIKE, and IS NULL. We will use a sample employee table with Bangladeshi names.

📁 Sample Employees Table

ID First Name Last Name Department Salary Email
201RakibHasanIT70000rakib@company.com
202TamannaSultanaHR55000tamanna@company.com
203ImranAhmedSales72000
204SharminJahanMarketing60000sharmin@company.com
205NaeemIslamITNULLnaeem@company.com

đŸ§Ē SQL Practice Queries with Explanation

1. AND – Filter by Department and Salary

SELECT * FROM employees
WHERE department = 'IT' AND salary > 60000;

This shows employees who are in IT department and have salary above 60,000.

2. OR – Either Department is HR or Salary below 60,000

SELECT * FROM employees
WHERE department = 'HR' OR salary < 60000;

Returns anyone from HR or anyone earning less than 60,000.

3. IN – Match Any Value from a List

SELECT * FROM employees
WHERE department IN ('HR', 'Sales');

Shows employees who are either in HR or Sales departments.

4. BETWEEN – Salary Between 55000 and 70000

SELECT * FROM employees
WHERE salary BETWEEN 55000 AND 70000;

Returns employees whose salary is in the range 55,000–70,000 inclusive.

5. LIKE – Name Starting with 'Sh'

SELECT * FROM employees
WHERE first_name LIKE 'Sh%';

Finds all employees whose first name starts with "Sh", such as "Sharmin".

6. IS NULL – Email Field is Empty

SELECT * FROM employees
WHERE email IS NULL;

Returns records where the email is missing (NULL).

📌 Summary

  • AND – Both conditions must be true
  • OR – Either condition can be true
  • IN – Match against multiple values
  • BETWEEN – Check if value is in a range
  • LIKE – Pattern matching (use % for wildcard)
  • IS NULL – Checks if a value is missing
✅ These SQL operators are essential for real-life data filtering. Practice them regularly to sharpen your SQL query skills.
SQL WHERE AND OR, SQL IN BETWEEN LIKE, SQL IS NULL example, SQL Bangla tutorial, SQL filtering practice, SQL operators explained, learn SQL in English, SQL with Bangladeshi dataset, SQL beginner guide, SQL Blogspot tutorial

āĻ•োāύ āĻŽāύ্āϤāĻŦ্āϝ āύেāχ:

āĻāĻ•āϟি āĻŽāύ্āϤāĻŦ্āϝ āĻĒোāϏ্āϟ āĻ•āϰুāύ