简体   繁体   English

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

[英]MS Access query in PHP returns no results

I have a query in MS Access that is saved and works when launched directly from ms access. 我在MS Access中有一个查询,该查询已保存,当直接从ms Access启动时可以运行。

I created a php page that outputs that information by calling this query by name, but query does not return anything! 我创建了一个php页面,该页面通过按名称调用此查询来输出该信息,但是查询不返回任何内容! My code should work since there are other queries in Access which I call, and they do return data. 我的代码应该可以工作,因为在Access中还有其他我要调用的查询,它们确实会返回数据。

  • Query works when launched(double-clicked) in Access 查询在Access中启动(双击)时有效
  • Query does not return results when typed and executed from PHP "SELECT * see query below" 从PHP输入并执行查询时,查询不返回结果"SELECT * see query below"
  • Query does not return results when called by MS Access-name from PHP "SELECT * FROM Query1" 通过PHP的MS Access-name调用"SELECT * FROM Query1"时,查询不返回结果
  • Other queries in the same database executed as expected when called by MS Access-name from PHP "SELECT * FROM Query2" 由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;  

Seems like complex query made this problem. 似乎是复杂的查询导致了此问题。 I had to optimize the query and then it worked. 我必须优化查询,然后它才能工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM