Another option depending on what you're doing with the results is to loop
the records into an array. You can then work with the result set using
array functions like count( ) and slice( ). YMMV.

Alfredo Delgado / Web Development
6800 Broken Sound Pkwy, Suite 150
Boca Raton, Florida 33487
(561) 443-9152 - Desk
(561) 350-4143 - Cell
(561) 443-9108 - Fax
-----web400-bounces@xxxxxxxxxxxx wrote: -----

To: Web Enabling the AS400 / iSeries <web400@xxxxxxxxxxxx>
From: Nathan Andelin <nandelin@xxxxxxxxx>
Sent by: web400-bounces@xxxxxxxxxxxx
Date: 12/15/2009 11:19
Subject: Re: [WEB400] getting number of records returned by SQL in PHP

I think you'll be pleased with the performance of select count(*) for
most result sets, even though it would be running a two select
statements. That may be what is doing under the covers, too.
You and your users can decide whether the added overhead is worth it.


----- Original Message ----
From: Larry Kleinman <larry@xxxxxxxxxxxxxxxxx>
To: Web Enabling the AS400 / iSeries <web400@xxxxxxxxxxxx>
Sent: Tue, December 15, 2009 8:52:47 AM
Subject: Re: [WEB400] getting number of records returned by SQL in PHP

Unless I do a GROUP BY (which I do not want to do), I don't think that I
can use the SELECT COUNT(*) and also get the actual fields returned in a
single SQL query, can I? That would mean that I would have to run the
query twice, once to get the data and once to get the count. Not a
thing to do from a performance point of view

Larry Kleinman
Kleinman Associates, Inc.

This is the Web Enabling the AS400 / iSeries (WEB400) mailing list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: [1]
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at [2]


Visible links

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2020 by and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].