我有一张基于from_date
和to_date
的房间费用表:
db的格式:
planid | roomtype_id | capacity_id | hotel_id |date_from | date_to | cost
我希望根据到货日期获得房间费用,当arrival_date
介于date_from
和date_to
我的代码:
$result1 = mysql_query("SELECT * FROM room_price WHERE roomtype_id = '$roomtype_id' AND capacity_id = '$capacity_id' AND hotel_id = '$hotel_id' AND date_from '$date' BETWEEN date_from AND date_to");
查询没有给出任何输出。
答案 0 :(得分:2)
问题是,你的\在mysql表colum中使用了两个日期,所以你必须检查我给出的代码如下:
$result1 = mysql_query("SELECT * FROM room_price WHERE roomtype_id = '$roomtype_id' AND capacity_id = '$capacity_id' AND hotel_id = '$hotel_id' AND date_from >='$date' And date_to<=$date");
答案 1 :(得分:0)
尝试此查询:
$result1 = mysql_query("SELECT * FROM room_price WHERE roomtype_id = '$roomtype_id' AND capacity_id = '$capacity_id' AND hotel_id = '$hotel_id' AND BETWEEN 'your_from_Date' AND 'your_to_date'");