Hi
I want to "barge" in on this question, as it has bothered me in the past
as well.
The reason being:
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?


On Thu, 2002-10-31 at 11:55, Egor Egorov wrote:
> Aamer,
> Wednesday, October 30, 2002, 8:34:44 PM, you wrote:
> 
> AR> I have a mysql database. Lets say it has a table called "maintable" with primary
> AR> key as main_id. I want to add other tables to the database and use main_id as 
> AR> foriegn keys in those tables. If I want to start with the last row of the 
> AR> maintable how can I using a perl script get main_id from the last row of the 
> AR> maintable. Note that maintable and the new added tables will keep growing in 
> AR> size.
> 
> If main_id is an auto_increment field, you can use LAST_INSERT_ID()
> function to retrieve inserted value:
>          http://www.mysql.com/doc/en/Miscellaneous_functions.html
> 
> Otherwise you should know what value you have inserted to the table :)
> 
> 
> 
> -- 
> For technical support contracts, goto https://order.mysql.com/?ref=ensita
> This email is sponsored by Ensita.net http://www.ensita.net/
>    __  ___     ___ ____  __
>   /  |/  /_ __/ __/ __ \/ /    Egor Egorov
>  / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
> /_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
>        <___/   www.mysql.com
> 
> 
> 
> 
> ---------------------------------------------------------------------
> 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
> 


---------------------------------------------------------------------
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