Re: last entry in mysql
| From: | Steve Edberg | Date: | Wed, 12 Dec 2001 19:26:09 +0000 |
| Subject: | Re: last entry in mysql | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-77475@lists.php.net to get a copy of this message | ||
This may be stating the obvious, but:
(1) Does your table have an auto_increment column?
(2) If so, did a previous query in the program - for example, an INSERT - generate a new record with an auto_incremented value? AFAIK, mysql_insert_id() won't return the last id unless you have a previous query in that same program that INSERTED/UPDATED an auto_incremented column.
If you want the maximum value of the column, you can always issue the query:
SELECT
max(your_auto_incremented_column_name_here)
FROM
your_table_name_here
At 10:30 AM -0600 12/12/01, Yoed Anis wrote:
hey guys, quick question I'm having trouble finding an answer too. In a mysql database, how can I select that last row entry. This might be done mins after i put that entry there and i tried to use: $lastid=mysql_insert_id(); to get the last id but to no avail. Thanks Yoed-- +------------------------------------------------------------------------+ | Steve Edberg sbedberg@ucdavis.edu | | University of California, Davis (530)754-9127 | | Programming/Database/SysAdmin http://pgfsun.ucdavis.edu/ | +------------------------------------------------------------------------+ | "Restriction of free thought and free speech is the most dangerous of | | all subversions. It is the one un-American act that could most easily | | defeat us." | | - Supreme Court Justice (1939-1975) William O. Douglas | +------------------------------------------------------------------------+