Я использую Oracle 11g, и я не знаю, почему мой запрос возвращает другой результат, когда я использую SQL / PLUS и когда я использую PHP
<?php
$conn=oci_connect('system','3636','orcl');
$stid = oci_parse($conn,
"SELECT num_chb
FROM chambre
WHERE num_chb NOT IN
(SELECT DISTINCT r.num_chb
FROM chambre c,
reservation r
WHERE (TO_DATE('2015-12-13','YYYY-MM-DD') NOT BETWEEN r.dat_arriv AND r.dat_depart)
AND (TO_DATE('2015-12-14','YYYY-MM-DD') NOT BETWEEN r.dat_arriv AND r.dat_depart)");
oci_execute($stid);
$tab=array();
while ($row = oci_fetch_assoc($stid)) {
$tab[]=$row['NUM_CHB'];
}
print_r($tab);
}
?>
SQL PLUS и PHP РЕЗУЛЬТАТ
Я вижу разные запросы:
PHP:
SELECT num_chb
FROM chambre
WHERE num_chb NOT IN
(SELECT DISTINCT r.num_chb
FROM chambre c,
reservation r
WHERE (TO_DATE('2015-12-13','YYYY-MM-DD') NOT BETWEEN r.dat_arriv AND r.dat_depart)
AND (TO_DATE('2015-12-14','YYYY-MM-DD') NOT BETWEEN r.dat_arriv AND r.dat_depart)
Oracle:
SELECT num_chb
FROM chambre
WHERE num_chb NOT IN
(SELECT DISTINCT r.num_chb
FROM chambre c,
reservation r
WHERE (TO_DATE('2015-12-13','YYYY-MM-DD') NOT BETWEEN r.dat_arriv AND r.dat_depart)
AND (TO_DATE('2015-12-14','YYYY-MM-DD') NOT BETWEEN r.dat_arriv AND r.dat_depart)
AND (r.dat_arriv TO_DATE('2015-12-13','YYYY-MM-DD') NOT BETWEEN AND TO_DATE('2015-12-14','YYYY-MM-DD'))
AND (r.dat_depart NOT BETWEEN TO_DATE('2015-12-14','YYYY-MM-DD') TO_DATE('2015-12-14','YYYY-MM-DD'))
PD: я не могу комментировать.
Проверьте еще раз!
Других решений пока нет …