相同的查询和不同的结果sql / plus php

时间:2015-11-07 18:22:45

标签: php oracle sqlplus

我使用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结果

SQL PLUS AND PHP RESULT

1 个答案:

答案 0 :(得分:0)

我看到了不同的疑问:

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)

甲骨文:

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:我不能发表评论。

再次检查!