GORAGOD.com

freelance, web developer, web designer, hosting, domain name

SUB SELECT QUERY กับเงื่อไข Between

SUB SELECT QUERY กับเงื่อไข Between รับค่าวันที่ มาตรวจสอบห้อง ระหว่างวันที่ ตามเงื่อนไขการจองห้อง ในระบบจองห้องพักครับ 




$startdate = $_POST[dateInput1]; // '2011-06-23';


$enddate = $_POST[dateInput2]; // '2011-06-24';



$sql_booking = "select * from booking where (('$startdate' NOT BETWEEN booking_checkin and booking_checkout) OR ('$enddate' NOT BETWEEN booking_checkin and booking_checkout)) AND booking_id in (select id_booking from booking_room where id_type_room = '".$booking_room['room_type_id']."')"; 



ค่าที่ออกมามี อยู่ 2 แถว ครับ ซึ่งถูกแล้ว แต่พอเปลี่ยนเงื่อนไขวันที่ เป็น




$startdate = $_POST[dateInput1]; // '2011-06-22';


$enddate = $_POST[dateInput2]; // '2011-06-24';



ซึ่งออกมา 4 แถว (ออกมาหมดที่มีข้อมูล) เหมือน SUB SELECT QUERY ตรง booking_id in (select id_booking from booking_room where id_type_room = '".$booking_room['room_type_id']."') มันจะไม่ทำงาน ไม่รู้ว่าคิวรี้ถูกหรือเปล่า ลองตรวจสอบให้ผมทีครับ 




26 Apr 2012 2 2,513

งงกับคำถามเธอ...



ลองดูบทความนะ
#1

ผมก็ งง กับมันเหมือนกัน ไม่รู้ว่าจะอธิบายยังไง 555+
#2
Comment
Upload jpg, jpeg files no larger than 2M
^