No results.... not even a zero. So what I did was something like this:

INSERT INTO table1 (field1,field2,field3)
SELECT table2.field1, table2.field2, table2.field2
FROM table2
WHERE table2.UID = SomeVariable;

SELECT MAX(table1.UID) FROM table1;

---------------------------
Now this assumes that UID is the unique ID number. Can you see a flaw in
this logic?


Dave Carter
Chief Web Architect
Accelerated Business Technologies, Inc.
http://www.abti.cc
717.464.2970

-----Original Message-----
From: Paul DuBois [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 25, 2001 4:25 PM
To: Dave Carter; [EMAIL PROTECTED]
Subject: Re: LAST_INSERT_ID Issues


At 9:48 AM -0400 5/25/01, Dave Carter wrote:
>This does not return any results
>
>SELECT LAST_INSERT_ID() FROM tablename;

It doesn't return *any* results? Or do you mean it returns 0?


FROM tablename is superfluous here; the most recent AUTO_INCREMENT value
is maintained on a per-connection basis. This means that if you want to
use this value, you must:
- Issue some statement (e.g., INSERT) that causes an AUTO_INCREMENT value
   to be generated, and
- You must select the value of LAST_INSERT_ID() within the *same* session.

If you issue the INSERT, then disconnect, reconnect, and retrieve the value
of LAST_INSERT_ID(), it won't work (you'll get zero), because that involves
two sessions with the server, not one.

>
>there is an indexed, auto-incrementing field in the table, but it refuses
to
>show any results. I don't understand the manual's text, so any help would
be
>appreciated.
>
>
>Dave Carter
>Chief Web Architect
>Accelerated Business Technologies, Inc.
>http://www.abti.cc
>717.464.2970
>
>grrrr sql,database


--
Paul DuBois, [EMAIL PROTECTED]


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