php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13799 PHP selects rows correctly but adds them up wrong
Submitted: 2001-10-23 08:46 UTC Modified: 2001-10-23 16:17 UTC
From: j dot ball at rgu dot ac dot uk Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 4.0.6 OS: Windows 98
Private report: No CVE-ID: None
 [2001-10-23 08:46 UTC] j dot ball at rgu dot ac dot uk
Using MySQL through the Apache server with a reproduction of the Northwind database (as supplied by MicroSoft).

The command:
SELECT DISTINCT Customers.* FROM Customers, Orders WHERE Customers.CustomerID = Orders.CustomerID;

This works OK when executed by MySQL in DOS (returning 20 records in my version of the Northwind Database).  In PHP the command also returns 20 records but PHP incorrectly reports "Showing records 0-30 (387)" at the top of the page.  If I leave out the 'DISTINCT' command I get the full 387 records with a correct report "Showing records 0-30 (387)".

I amend the query as follows:
SELECT DISTINCT Customers.* FROM Customers, Orders WHERE Customers.CustomerID = Orders.CustomerID ORDER BY Customers.CustomerID;

PHP now shows the same 20 records and declares "Showing records 0-20 (20)" this time correctly.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-10-23 09:02 UTC] sander@php.net
Probably not a bug in PHP, but in your script. Can you provide a sample script?
 [2001-10-23 09:51 UTC] j dot ball at rgu dot ac dot uk
I am accessing my database through phpMyAdmin-2.2.0 and not through my own script - so I know it is not any fault of my scripting abilities!   I obtained my copy of the script from SourceForge (http://sourceforge.net/projects/phpmyadmin/) 

On reflection, you guys might not have written this so perhaps I should report the bug to SourceForge... if this is the case then please accept my apologies and I will report the bug to SourceForge.

Regards

Jonathan

 [2001-10-23 16:17 UTC] jeroen@php.net
Not a bug in PHP. Mysql handles distinct count(*) wrong, iirc it's noted on their website.

PHPmyAdmin could work around this, but that's not the business of PHP. You could drop a line over there.

no bug in php -> bogus
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Oct 30 22:01:28 2024 UTC