Re: Couple of small questions
| From: | Bjørn André Lie | Date: | Mon, 20 Nov 2000 09:46:16 +0000 |
| Subject: | Re: Couple of small questions | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-26226@lists.php.net to get a copy of this message | ||
Hi,
Select count(*) from table_name will give you the number of records stored in a db table. With a lot of data this can take a lot of time. Some databases (eg. Sybase SQL AnyWhere) have a system-table that holds information about all the tables in the database (also the number of rows in a table). In that case you can select it from this table (fast eg. select count from SYS.SYSTABLE where table_name = 'table_name').
To add up Gram you can create a trigger (fire after insert) that calculates the sum of Gram and leaves the result in a temporary table. The select the sum of Gram (one row) and present this value.
Regards,
Bjørn André Lie
At 04:30 20.11.00 -0500, you wrote:
Hi again, Need some help with some math stuff. Firstly, what is the best method for obtaining the number of records stored in a db table? and secondly in a table I am storing a value under the name Gram every time a record is added this value is different what I am trying to do is select all the records take Gram from each record and add them all together, any ideas. TIA Ade -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net