Counting the Records in a Database Table

To find out how many records there are in a database table, use the number of records of table function as shown in the following example.

Example:

put the number of records of table "colorpalette" of myDB

To find out how many records match a particular condition in a database table, use the number of rows of table function along with an optional where clause as shown in the following example.

Example:

put the number of rows of table "colorpalette" of myDB where "color" is "black"

Another way to find out how many records match a particular condition in a database table is to add the database records to a variable, then use the number of records of variable function along with an optional where clause as shown in the following example.

Example:

put table "colorpalette" of myDB into colors

get number of records of colors where color is "green"

Log "There are " & it & " record(s) in the table."

Asking directly for the number of records in a table sends a count request to the database. The count request returns the number, rather than the records, making this approach much more efficient than fetching the records and asking for the number of items in the returned list as shown in the following example.

Example:

put the records of table "memberinfo" of myDB into members

put the number of items in members

 

This topic was last updated on January 15, 2020, at 03:27:21 PM.

Eggplant icon Eggplantsoftware.com | Documentation Home | User Forums | Support | Copyright © 2020 Eggplant