First, MySQL get the current field maximum ID
SQL statement:
Select Max (id) from yourtable;
Second, obtain the MySQL table self-increase (auto_increment) value
Auto_increment
is a property in a table that can be obtained by taking the state of a table to the self-increment
SQL statement:
Show table status like "table name";
PHP Code implementation
$get _table_status_sql = "Show table status like ' table name '";
$result = mysql_query ($get _table_status_sql);
$table _status = mysql_fetch_array ($result);
echo $table _status[' auto_increment ']; This is the self-appreciation
Or
Select Max (id) from Testnotnull;
Three, get the total number of records of a table
Select COUNT (*) from table;
Or
Select COUNT (id) from table;
SELECT sql_calc_found_rows * FROM table_name;
SELECT found_rows ();
myisam
The next count(*)
primary key is conditional, this condition is a Type field, the index is invalid
No conditions very fast, added after the slow two orders of magnitude
Using SHOW TABLE STATUS
statements is the most efficient method
Format
Show TABLE STATUS [{from | in} db_name] [as ' pattern ' | WHERE Expr]
Example:
Show TABLE STATUS from cpdlt like ' lehecai_1202 ';
Summarize
The above is for everyone to organize how to get a table record number, get a table of the largest ID and get a table of auto_increment value, and other related issues of all content, I hope that the study or work to bring some help, if you have questions you can message exchange.