首页 > 解决方案 > 当我使用'NOT IN'使用sql进行查询时,php函数不会从sql返回结果

问题描述

我使用 sql 命令从 oracle 服务器中选择数据并得到这样的结果

select *
  from login_log
  where userid not in (select userid
                         from last_log
                         where userid is not null) and
        LOGIN_ID='423'

但是当我在 php 函数中使用这个 sql 时它不会返回任何东西

$strSQL = "select * from login_log where userid not in (select userid from last_log where userid is not null) and  LOGIN_ID='423'";
$objParse = oci_parse($objConnect, $strSQL);
oci_bind_by_name($objParse, ':sftp_id', $sftp_id);
oci_execute($objParse, OCI_DEFAULT);
$nrows = oci_fetch_all($objParse, $results, null, null, OCI_FETCHSTATEMENT_BY_ROW);

我不知道为什么我没有得到“NOT IN”的结果我尝试通过像这样将“NOT IN”更改为“IN”来测试代码

$strSQL = "select * from login_log where userid in (select userid from last_log where userid is not null) and  LOGIN_ID='423'";

它是正常返回结果,我不知道发生了什么。任何机构都可以帮助我吗?

标签: phpsqloracle

解决方案


我会说这是因为 id423存在,当您的查询要求不存在时,它不会返回任何内容,因为代码是最新且正确的。


推荐阅读