🔹 WHERE Clause

Definition: The WHERE clause is used to filter records. It fetches only those rows that meet a specified condition.
Syntax:
SELECT column1, column2, ...
FROM table_name
WHERE condition;

🎓 Sample Table: students

idnameagegrade
1Asha15A
2Rohan14B
3Meena16A
4Vikram15C
SELECT * FROM students WHERE grade = 'A';

🟢 Output: Returns students who scored grade A.

idnameagegrade
1Asha15A
3Meena16A
SELECT name FROM students WHERE age > 14;

🟢 Output: Shows names of students older than 14.

name
Asha
Meena
Vikram
📌 When to Use WHERE: Use the WHERE clause when you want to retrieve only specific records based on a condition (e.g., grade = 'A' or age > 15).
⚠️ Common Mistakes:
  • Using = for numeric comparisons without quotes — works fine, but avoid quotes for numbers.
  • Forgetting to wrap string values in single quotes (e.g., grade = A instead of grade = 'A').
  • Misspelled column names.