At 21:11 -0400 5/5/04, Erich Beyrent wrote:
Hi there,

I seem to be having a problem retrieving the last inserted ID for a
table.

The query I am using is as follows:

mysql> select distinct LAST_INSERT_ID() as LastID from listings;

This can be simplified as SELECT LAST_INSERT_ID as LastID; no need to retrieve the value once for every row in the listings table.

+--------+
| LastID |
+--------+
|   3575 |
+--------+
1 row in set (0.00 sec)

However, when I run this from my PHP script, I get a value of 0.

Assuming you're issing the query using the same connection as that on which you generate the ID, it should work. Hard to say why it might now without seeing the code.


Any clues as to how to resolve this?


Thanks!

-Erich-


--
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to