SQL Where clause is used to filter records in a database table, allowing you to retrieve only the rows that meet specific conditions.
SQL Where Syntax
SQL
x
1
SELECT column1, column2, ...
2
FROM table_name
3
WHERE condition;
SQL Where Examples
SQL Where Filtering by a Single Condition Example
This query retieves all columns from the students table for rows where the NAME starts with the letter ‘A’.
SQL
1
1
SELECT * FROM Students
2
WHERE name LIKE 'A%';

SQL Where Combining Multiple Conditions with AND
This query retrieves all columns from the PATIENTS table for rows where the gender is ‘M’ (male) and the contact_number is not NULL.
SQL
1
1
SELECT * FROM Patients
2
WHERE gender = 'M' AND contact_number IS NOT NULL;

SQL Where Using OR to Broade the Search
This query retrieves all columns from the DOCTORS table for rows where the specialty is either ‘Cardiology’ or ‘Neurology’.
SQL
1
1
SELECT * FROM Doctors
2
WHERE specialty = 'Cardiology' OR specialty = 'Neurology';

SQL Where Visual Diagram
