Page 1 of 1

count colums and tables

Posted: Wed Oct 28, 2009 5:38 am
by ranjitbd

Code: Select all

 
// how to get the number of tables in a database in mysql
 
// how to get the total number of columns in a row 
 
 
 

Re: count colums and tables

Posted: Fri Oct 30, 2009 2:20 pm
by akuji36
Hello try this for your columns:

http://www.webmasterworld.com/forum88/10947.htm

mysql can show tables:

show tables

here:

http://dev.mysql.com/doc/refman/5.0/en/show-tables.html

thanks

Rod

Re: count colums and tables

Posted: Thu Nov 05, 2009 3:56 am
by ranjitbd
ranjitbd wrote:

Code: Select all

 
// how to get the number of tables in a database in mysql
 
// how to get the total number of columns in a row 
 
 
 
// i came to know that the number of tables in the database like 20, 30 or 40
// show tables column will show the table name...

Re: count colums and tables

Posted: Thu Nov 05, 2009 9:59 am
by AbraCadaver

Code: Select all

// how to get the number of tables in a database in mysql
$result = mysql_query("SHOW TABLES FROM database_name");
$table_count = mysql_num_rows($result);
AND

Code: Select all

// how to get the total number of columns in a row
$result = mysql_query("SHOW COLUMNS FROM database_name.table_name");
$field_count = mysql_num_rows($result);
--or--

Code: Select all

// how to get the total number of columns in a row
$result = mysql_query("DESCRIBE database_name.table_name");
$field_count = mysql_num_rows($result); 
--or--

Code: Select all

// how to get the total number of columns in a row
$result = mysql_query("SELECT * FROM database_name.table_name LIMIT 1");
$field_count = mysql_num_fields($result); 
-Shawn