![](/img/trans.png)
[英]Select statement that counts matching dates (not time) from a timestamp in sql
[英]How to fetch dates from SQL by matching my travel dates?
如何獲取關於hotel_id
, occu_type
, season_start
和season_end
旅行日期?
例如,如果我的旅行日期介於兩次會議之間,則我的日期為30/08 / 2015、31 / 08 / 2015、01 / 09 / 2015、02 / 09/2015和03/09/2015。
我在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)
);
數據庫:-
http://www93.zippyshare.com/v/H33KasNa/file.html http://www39.zippyshare.com/v/KO2qYYyu/file.html
請分享任何解決方案...
據我了解,您正在選擇兩個日期范圍,對嗎?
dateStart1 dateEnd1
和
dateStart2 dateEnd2
查詢將是這樣的:
...和(season_start <= dateStart1和dateEnd1 <= season_end)和(season_start <= dateStart2和season_end <= dateEnd2)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.