简体   繁体   中英

How to fetch dates from SQL by matching my travel dates?

How to fetch my travel dates with respect to hotel_id , occu_type , season_start & season_end ?

If my travel dates lies between two sessions for example my dates are 30/08/2015,31/08/2015,01/09/2015,02/09/2015 and 03/09/2015.

I am using following query for this in PDO...

$sql = $this->dbObj->query(
  select DISTINCT season_start, season_end from nwts_hotel_room_rate 
  where hotel_id = '".$hotelid."' and occu_type = '".$arrayRmtypeopt."' and
    ('".$arrardepDate."' >= season_start and '".$arrardepDate."' < season_end)
  );

Database:-

http://www93.zippyshare.com/v/H33KasNa/file.html http://www39.zippyshare.com/v/KO2qYYyu/file.html

Please share any solution...

As I understood you're picking two date periods, right?

dateStart1 dateEnd1

and

dateStart2 dateEnd2

Query will be something like this:

... and (season_start <= dateStart1 and dateEnd1 <= season_end) and (season_start <= dateStart2 and season_end <= dateEnd2)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM