PHP中的MS Access查询不返回任何结果

时间:2013-11-20 17:16:30

标签: php sql ms-access pdo odbc

我在MS Access中有一个保存的查询,直接从ms访问启动时可以正常工作。

我创建了一个php页面,通过按名称调用此查询来输出该信息,但查询不返回任何内容! 我的代码应该可以工作,因为在我调用的Access中有其他查询,它们确实会返回数据。

  • 在Access
  • 中启动(双击)时查询有效
  • 从PHP "SELECT * see query below"
  • 键入和执行时,查询不会返回结果
  • 从PHP "SELECT * FROM Query1"
  • 中的MS Access-name调用时,查询不返回结果
  • 来自PHP "SELECT * FROM Query2"的MS Access-name调用时,预期执行的同一数据库中的其他查询

SELECT * 
FROM   (SELECT a2.[vendor_oel_yr], 
               Count(a2.qty) AS eol_qty 
        FROM   (SELECT "wintel"                               AS Platform, 
                       s.city & "," & s.state                AS 
                       [Physical Location], 
                       ""                                     AS 
                       [Special Flag (Project)], 
                       ""                                     AS 
                       [Special Flag (sub location)], 
                       ""                                     AS 
                       [location Floor], 
                       ""                                     AS 
                       [Room Discriptor], 
                       Format(s.unitprce, "currency")         AS [Unit Price], 
                       "hp"                                   AS Manufacturer, 
                       t.make_model                           AS Model, 
                       s.itemnmbr                             AS [Part Number], 
                       s.qty                                  AS Qty, 
                       s.itemdesc                             AS Description, 
                       s.sn                                   AS [Serial Number] 
                       , 
                       "" 
                       AS [Asset Tag #], 
                       ""                                     AS Environment, 
                       t.computer                             AS 
                               [Device Name (Naming Standard)], 
                       s.docdate                              AS [Install Date], 
                       4                                      AS 
                       [Vendor Useful Life], 
                       ""                                     AS 
                       [Operational Useful Life], 
                       s.docdate + ( 4 * 365 )                AS 
                       [Vendor EOL Date], 
                       ""                                     AS 
                       [Operational EOL Date] 
                       , 
                       Format(s.qty * s.unitprce, "currency") AS 
                       [Purchase Price], 
                       Year(s.docdate + ( 4 * 365 ))          AS Vendor_OEL_Yr 
                FROM   sayers_invoice AS s 
                       INNER JOIN tamit_wintel AS t 
                               ON s.sn = t.serial_number 
                WHERE  Len(s.sn) > 0) AS a2 
        GROUP  BY a2.[vendor_oel_yr]) AS a2O;  

1 个答案:

答案 0 :(得分:0)

似乎复杂的查询造成了这个问题。 我必须优化查询,然后才能工作。