Q: 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.
I created a php page that outputs that information by calling this query by name, but query does not return anything!
My code should work since there are other queries in Access which I call, and they do return data.


*

*Query works when launched(double-clicked) in Access

*Query does not return results when typed and executed from PHP "SELECT * see query below"

*Query does not return results when called by MS Access-name from PHP "SELECT * FROM Query1"

*Other queries in the same database executed as expected when called by MS Access-name from PHP "SELECT * FROM Query2"

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;  


A: Seems like complex query made this problem.
I had to optimize the query and then it worked.
