Helllo All !!

I 've a problem i want to retrieve the primary key value of the last
Inserted record in a table and use it in another table.
My Table is
TRANS
( transID int not null auto_increment primary key,
.
....
...
..
)
Ordertable
(OrderID int not null auto_increment primary key,
transID int  => this represents the last inserted record's primary key
.....
...
...
..
) ;

I did
select Last_Insert_Id () from trans ;
| last_insert_id() |
+------------------+
|               18 |
|               18 |
|               18 |
|               18 |
|               18 |
|               18 |
|               18 |
|               18 |
|               18 |
|               18 |
|               18 |
|               18 |
|               18 |
|               18 |
|               18 |
|               18 |
|               18 |
|               18 |
|               18 |
+------------------+
19 rows in set (0.05 sec)
how is that 18 times but 19 rows ???????
Next i did select Last_Insert_Id (transid) from trans ;
result
| last_Insert_Id(transId) |
+-------------------------+
|                       1 |
|                       2 |
|                       3 |
|                       4 |
|                       5 |
|                       6 |
|                       7 |
|                       8 |
|                       9 |
|                      10 |
|                      11 |
|                      12 |
|                      13 |
|                      14 |
|                      15 |
|                      16 |
|                      17 |
|                      18 |
|                      19 |
+-------------------------+
19 rows in set (0.00 sec)

Surely it beats me , Could anyone explain this
I just want to retrieve a single value  that's 19
or should i do a   select  count(*) from trans to get that value ????
Any help will be greatly appreciated
Best Regards
Sajan





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