SQL And

The SQL And operator is used to combine multiple conditions in a WHERE clause. When you use AND, the query returns only the rows that meet all of the conditions specified.

SQL And Syntax

SELECT column1, column2, ...
FROM table_name
WHERE condition1 AND condition2 AND ...;



SQL And Example

SQL And Simple AND Condition Example

This query retrieves the first_name, last_name, and dob (date of birth) columns from the PATIENTS table for female patients (gender = ‘F’) who were born after January 1, 1985.

SELECT first_name, last_name, dob
FROM Patients
WHERE gender = 'F' AND dob > '1985-01-01';



SQL And Using AND with Multiple Conditions Example

This query retrieves the first_name, last_name, and contact_number columns from the PATIENTS table for male patients (gender = ‘M’) who were born before January 1, 1990 (dob < ‘1990-01-01’). Additionaly, it only includes those male patients whose contact_number is not NULL.

SELECT first_name, last_name, contact_number
FROM Patients
WHERE gender = 'M' AND dob < '1990-01-01' AND contact_number IS NOT NULL;




SQL And Visual Diagram




SQL And Labs

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top