Hi,
Your query was understood as - you want to retrieve the current value of
the autoincrement column, where mysql_insert_id also reveals the same.
Try either of this.
Use LIMIT:
select ID from tablename
order by ID DESC
LIMIT 1.
or
Use MAX()
select MAX(ID) from tablename
Thank
On Wed, 2004-05-05 at 22:49, Paul DuBois wrote:
> At 22:39 -0400 5/5/04, Nathan Jones 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:
> >>
> >
> >It's far easier than anyone else has m
> Well, you don't need the distinct.
>
> Are you inserting with your PHP script? LAST_INSERT_ID(), as per the
>
> manual,
> only returns the id from the last insert on that connect. You cannot
get >the
> LAST_INSERT_ID() for another connection.
j- k-
I used distinct because otherwise
At 22:39 -0400 5/5/04, Nathan Jones 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:
It's far easier than anyone else has mentioned, as of my writing. Just
use the PHP function 'mysql_insert_id()' after your inse
> 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:
>
It's far easier than anyone else has mentioned, as of my writing. Just
use the PHP function 'mysql_insert_id()' after your insert query. This
function has bee
At 20:34 -0500 5/5/04, Paul DuBois wrote:
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
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
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;
++
| LastID |
++
| 3575 |
++
1 row in set (0.00 sec)
Ho
Well, you don't need the distinct.
Are you inserting with your PHP script? LAST_INSERT_ID(), as per the manual,
only returns the id from the last insert on that connect. You cannot get the
LAST_INSERT_ID() for another connection.
j- k-
On Wednesday 05 May 2004 05:11 pm, Erich Beyrent
This will only be a problem if the two inserts are using the same mysql connection/link_indentifier.
This isn't usually the case in a web environment, unless you are using a persistent mysql connection across multiple instances of the same script.
mysql_insert_id() returns the last insert id for
At 9:33 + 2/19/04, Mark Maunder wrote:
'connection ID' below should be 'last insert id'. Sorry, it's 2am here
and I'm fresh out of coffee. BTW the information you want is here:
http://www.mysql.com/doc/en/Information_functions.html#IDX1409
"The last ID that was generated is maintained in the se
Thanks Mark...
You popped me out of great confusion/problem.
Binay
- Original Message -
From: "Mark Maunder" <[EMAIL PROTECTED]>
To: "Binay" <[EMAIL PROTECTED]>
Cc: "mysql users" <[EMAIL PROTECTED]>
Sent: Thursday, February 19, 2004 3:03
"Binay" <[EMAIL PROTECTED]> wrote:
> Hi
>
> I have a php script which insert a row in one of my table. Now i want the
> auto_generated id produced by this insert query. I know i can use mysql_insert_id
> function to fetch that auto_generated id. But my question is say two or more person
> visit
'connection ID' below should be 'last insert id'. Sorry, it's 2am here
and I'm fresh out of coffee. BTW the information you want is here:
http://www.mysql.com/doc/en/Information_functions.html#IDX1409
"The last ID that was generated is maintained in the server on a
per-connection basis. This means
The two simultaneous insert statements will be have separate connections
to the database and last_insert_id() is connection specific. So if
you're running apache, and you're worried about two different apache
child processes getting the same connection ID, don't. Because those two
children will hav
15 matches
Mail list logo