"Peter R. Wood - Mailing Lists" wrote:

> When he deletes an assignment from the class, it deletes it from both tables.
> 
> However, after this, if he adds an assignment again, the unique ID generated
> by insertion into the assignment table is one greater than it should be -
> i.e., it auto increments the id based on the id of the row that just got
> deleted, not on the last row that is actually in the table. When the
> assignment is inserted into the student_assignment table, the unique ID is
> auto incremented based on the last ID that is actually in the table, not on
> the row that just got deleted.
> 
> The workaround I have found is to use last_insert_id() to find the ID that
> got inserted in to the assignment table, and use this to manually specify the
> ID for the student_assignment table.  This has the effect of putting the ID's
> in sync, which is what I want, but it seems like there should be a better
> solution. Any suggestions?

This is correct behaviour. auto_increment always gives new value when
empty value gets inserted. Best way is what you already do. Another
workaround can be made if you remember old ID somewhere and insert it
into both tables together with new records. 

-- 
MySQL Development Team
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /   Tonu Samuel <[EMAIL PROTECTED]>
 / /|_/ / // /\ \/ /_/ / /__  MySQL AB, http://www.mysql.com/
/_/  /_/\_, /___/\___\_\___/  Tallinn, Estonia
       <___/

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