I have ‘rental’ table with the following columns – id, date_from, date_to
I am trying to find if there are any rentals between two dates (to look up available inventory). I tried the following query and it works – SELECT * FROM 'rental' WHERE ('date_from' BETWEEN '2022-06-15' AND '2022-06-17') OR ('date_to' BETWEEN '2022-06-15' AND '2022-06-17');
However, if a rental record exists in database that starts before 2022-06-15 and ends after 2022-06-17, this query does not return that record.
How can I query active rentals within a date range? Thank you