How To Determine The Number Of Records

Table of contents:

How To Determine The Number Of Records
How To Determine The Number Of Records

Video: How To Determine The Number Of Records

Video: How To Determine The Number Of Records
Video: How to Determine the Number of Records in a File in CL program 2024, May
Anonim

You can find out the number of records in a database table either using an application or programmatically. This task is one of the easiest when working with databases, so the choice of a specific method depends only on the type of database and on what tools you have at your disposal. Below are the options for one of the most widely used DBMSs today - MySQL.

How to determine the number of records
How to determine the number of records

Necessary

PhpMyAdmin Application

Instructions

Step 1

Use, for example, the PhpMyAdmin application to find out the number of records in any database table you are interested in. This program is most often used for "manual" management of MySQL data due to its simplicity and very broad functionality. You can get a fresh distribution kit of the application for free on the manufacturer's website -

Step 2

Download the installed PhpMyAdmin application, log in and click the link with the name of the database you are interested in in the left pane. The program will load into the right pane a list of tables in this database, containing some general information about them. There will also be a column with the heading "Records" indicating the number of rows - find the required table in the list and look at the corresponding number of records.

Step 3

If you need to use the MySQL language to determine the number of rows in a table, then the required query can be composed in several ways. For small tables, the speed of execution of this query is not so important, but it is better for them to choose commands that require the least expenditure of computer resources from the DBMS. Based on this, write a query, for example, in the following form: SELECT COUNT (*) FROM `table_name` Here you need to replace the table_name with the name of the required table.

Step 4

Use the same PhpMyAdmin application or script in any programming language to send an SQL query to the database. To do this, in the application interface, select the required table from the list in the left pane, and then click the "SQL" link in the right pane menu. PhpMyAdmin will load a page with a default sample query (s) in the "Execute SQL query (s) against mysql database" field. Correct it and click OK - the application will send a request to the server and display the result. And if you need to send a request programmatically, use the syntax of the programming language in which the program is written. For example, in PHP it might look like this: $ countRows = mysql_query ("SELECT COUNT (*) FROM` table_name` ");

Recommended: