* Petre Agenbag
[...]
> I did the last write to the table maybe a day ago, but I want to write a
> script that can give me some "stats" on the table at any time, so it
> also makes sense to me to be able to have a get_last_entry() function,
> or a total_rows_in table() (well, I guess you can do that with a select
> * from table), but I think where the problem comes in with
> last_insert_id(), is that you actually have to insert something into the
> table to get the last id, and I don't always want to insert something in
> the table?
> Is there a way to do that?

The number of rows in a table at the time of the query:

  select count(*) from table;

The highest id in the table at the time of the query:

  select max(id) from table;

The problem with these methods is that you can not know if the result is
still correct when you want to use it (unless you somehow lock the tables,
so that no other process can insert new rows). Depending on your
application, this may not be important.

last_insert_id() is allways safe, but it may not be what you need in this
case.

--
Roger
sql


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to