SQL Between

The SQL Between operator is used to filter the results of a query by specifying a range of values. This operator is inclusive, meaning it will include the start and end values in the result set.

Tutorials dojo strip

SQL Between Syntax

SELECT column_name(s)
FROM table_name
WHERE column_name BETWEEN value1 AND value2;

SQL Between Finding Patients Born Between Dates Example

This query searches the Patients table for records where the dob (date of birth) falls between the specified range.

SELECT first_name, last_name, dob 
FROM Patients 
WHERE dob BETWEEN '1980-01-01' AND '1990-12-31';

SQL Between Selecting Appointments Within a Specific Date Range Example

This query filters the Appointments table to show appintments scheduled within the given date range, including the specified start and end dates.

SELECT appointment_id, patient_id, doctor_id, appointment_date 
FROM Appointments 
WHERE appointment_date BETWEEN '2024-07-20' AND '2024-07-25';

SQL Between Visual Diagram

SQL Between Labs

Tutorials dojo strip
Tutorials dojo strip
Scroll to Top