At 02:10 PM 4/23/2002, you wrote:
>query, table
>
>When I run the query:
>
>SELECT LAST_INSERT_ID() as id FROM myTable;
>
>It returns the last inserted Id, but why does it return that value for every
>row in the table.
>
>for example.
>if there are 5 total records in the table. and the last inserted Id is 9, if
>I run the above query I get:
>
>+------+
>|    id     |
>+------+
>|    9      |
>|    9      |
>|    9      |
>|    9      |
>|    9      |
>+------+
>

Destr0,
         Because it is a constant. You don't add the table name to the 
query. Try

SELECT LAST_INSERT_ID() as id;

         And you will get one row, namely the last auto inc value for the 
last table that had a row inserted. You normally use this right after you 
have inserted a row to a table, so you automatically know which table it is 
for.

Brent


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.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

Reply via email to