php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26479 ORDER BY clause not sorting results
Submitted: 2003-11-30 20:42 UTC Modified: 2003-12-01 02:24 UTC
From: andrew at howsfamily dot net Assigned:
Status: Not a bug Package: ODBC related
PHP Version: 4.3.2 OS: Windows XP Pro
Private report: No CVE-ID: None
 [2003-11-30 20:42 UTC] andrew at howsfamily dot net
Description:
------------
When running a query, the ORDER BY clause seems to be ignored.  ODBC is connecting to MS Access via the standard MS driver. When the query is run in a MS Access query, it sorts correctly. When the resultset is returned via the PHP ODBC functions, however, the rows are returned in the order they were created, not the order specified by the ORDER BY clause.

Reproduce code:
---------------
SELECT Person.Surname, Person.[Given Name(s)], Owing - IIF(Payments.Total IS NULL, '0', Payments.Total) AS Amount 
FROM Person, Registration,

(SELECT Registration.Surname, Registration.[Given Name(s)], SUM(Amount) AS Total
FROM Registration LEFT OUTER JOIN Receipt ON (Registration.Camp = Receipt.Camp) AND (Registration.Surname = Receipt.Surname) AND (Registration.[Given Name(s)] = Receipt.[Given Name(s)])
WHERE Registration.Camp='Summer Camp 2003' GROUP BY Registration.Surname, Registration.[Given Name(s)], Registration.Owing) AS Payments

WHERE Person.[Given Name(s)] = Registration.[Given Name(s)] AND Person.Surname = Registration.Surname AND Person.[Given Name(s)] = Payments.[Given Name(s)] AND Person.Surname = Payments.Surname AND Camp = 'Summer Camp 2003' AND (Owing - IIF(Payments.Total IS NULL, '0', Payments.Total)) > 0 AND Person.[Given Name(s)] = Registration.[Given Name(s)] AND Person.Surname = Registration.Surname
ORDER BY Person.Surname

Expected result:
----------------
 SURNAME	 GIVEN NAME(S)	 AMOUNT
-------------------------------------------
 Aardvark   	 Fred   	 $130.00
 Badger  	 Bob  		 $150.00
 Dalmation  	 Jim  	 	 $150.00


Actual result:
--------------
 SURNAME	 GIVEN NAME(S)	 AMOUNT
-------------------------------------------
 Aardvark   	 Fred   	 $130.00
 Dalmation  	 Jim  	 	 $150.00
 Badger  	 Bob  		 $150.00


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-01 02:24 UTC] sniper@php.net
Not PHP bug.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 23:01:28 2024 UTC