>백엔드 개발 >PHP 튜토리얼 >sqlserver - 同一句sql在php里执行没有结果,在navicat里查询有结果是什么原因?

sqlserver - 同一句sql在php里执行没有结果,在navicat里查询有结果是什么原因?

WBOY
WBOY원래의
2016-06-06 20:23:531467검색

如题,同一句sql在php里执行没有结果,在navicat里查询有结果。

<code>SELECT
    TOP 25 SHANGPIN.SPDM,
    SHANGPIN.SPMC,
    GUIGE1.GGMC AS YS,
    SUM (VW_SDLSMX.SL) AS SL,
    FJSX3.SXMC AS SHEJI,
    FJSX4.SXMC AS DABAN
FROM
    SHANGPIN,
    GUIGE1,
    GUIGE2,
    VW_SDLSMX,
    FJSX3,
    FJSX4
WHERE
    VW_SDLSMX.SPDM = SHANGPIN.SPDM
AND VW_SDLSMX.GG1DM = GUIGE1.GGDM
AND VW_SDLSMX.GG2DM = GUIGE2.GGDM
AND VW_SDLSMX.DM1 != '900'
AND VW_SDLSMX.DM1 != '901'
AND SHANGPIN.FJSX3 = FJSX3.SXDM
AND SHANGPIN.FJSX4 = FJSX4.SXDM
AND VW_SDLSMX.SPDM IN (
    SELECT
        SPDM
    FROM
        SHANGPIN
    WHERE
        BYZD4 = '000'
    AND BYZD5 = 'eg'
)
GROUP BY
    SHANGPIN.SPDM,
    SHANGPIN.SPMC,
    GUIGE1.GGMC,
    FJSX3.SXMC,
    FJSX4.SXMC
ORDER BY
    SUM (SL) DESC</code>

回复内容:

如题,同一句sql在php里执行没有结果,在navicat里查询有结果。

<code>SELECT
    TOP 25 SHANGPIN.SPDM,
    SHANGPIN.SPMC,
    GUIGE1.GGMC AS YS,
    SUM (VW_SDLSMX.SL) AS SL,
    FJSX3.SXMC AS SHEJI,
    FJSX4.SXMC AS DABAN
FROM
    SHANGPIN,
    GUIGE1,
    GUIGE2,
    VW_SDLSMX,
    FJSX3,
    FJSX4
WHERE
    VW_SDLSMX.SPDM = SHANGPIN.SPDM
AND VW_SDLSMX.GG1DM = GUIGE1.GGDM
AND VW_SDLSMX.GG2DM = GUIGE2.GGDM
AND VW_SDLSMX.DM1 != '900'
AND VW_SDLSMX.DM1 != '901'
AND SHANGPIN.FJSX3 = FJSX3.SXDM
AND SHANGPIN.FJSX4 = FJSX4.SXDM
AND VW_SDLSMX.SPDM IN (
    SELECT
        SPDM
    FROM
        SHANGPIN
    WHERE
        BYZD4 = '000'
    AND BYZD5 = 'eg'
)
GROUP BY
    SHANGPIN.SPDM,
    SHANGPIN.SPMC,
    GUIGE1.GGMC,
    FJSX3.SXMC,
    FJSX4.SXMC
ORDER BY
    SUM (SL) DESC</code>

是不是没有 commit

打印出你的sql语句看下,可能传值的时候要加引号。如:变量='$...';

之前也遇到同样的情况,当时把语句复制到window s的记事本,再复制粘贴回回去,居然就好了。

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.