S
S
Seraphim Topal2020-12-29 18:52:36
SQL
Seraphim Topal, 2020-12-29 18:52:36

How to get a property available for booking on the specified days?

There is a certain table available , in which the admin indicates the days on which you can rent a property. There is a field from (starting from), to (last day) and there is a property_id field (this is actually the property id). It is not unique; accordingly, there may be several dates for the availability of housing. They may intersect. So, the question itself is: how to get a property available for booking on the specified days, given the fact that the records can overlap? Example:

from        to          property_id
2020-12-27  2021-01-08  1
2021-01-06  2021-01-15  1


The user specifies a date range: to(starting from) 2020-12-29 from(ending) 2021-01-12. You need to get real estate (more precisely, idshniks) that is suitable for renting these days.
An option like "make no overlapping dates for one property" is not suitable.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Seraphim Topal, 2021-02-05
@no4ch

In short, the best option is to either do it so that there is no "overlay" of dates on each other, or simply use this table to store "busy" days (for example, for cleaning, etc.)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question