Dear William,

>  The problem is...if I delete the third entry (Edicao = 3), the next
> entry inserted should be 3, right?! Well it is not! It is 4. So I get
a
> table like this...
>   +--------+
>   | Edicao |
>   +--------+
>   |      1 |
>   |      2 |
>   |      4 |

This is not a bug, it's a feature. Assume something like "staff number"
being an auto_increment column. Staff # 1234 gets layed off, all the
payments are cancelled, no holidays for # 1234 any more etc. Now, a new
employee gets the "empty" staff number 1234. He will never get his
salary, and no vacations at all, because he was layed off before he was
employed. This kind of confusion will not happen with auto_increment.

So, if you need things to be like "1 2 3 4 ..." you will have to use
this statement:

INSERT INTO my_table (Edicao) VALUES (last_insert_id + 1)
resp.
... VALUES (MAX(Edicao) +1)

Regards,

--
  Stefan Hinz
  Geschäftsführer / CEO iConnect e-commerce solutions GmbH
  #  www.js-webShop.com www.iConnect.de
  #  Gustav-Meyer-Allee 25, 13355 Berlin
  #  Tel: +49-30-46307-382  Fax: +49-30-46307-388

----- Original Message -----
From: "William N. Zanatta" <[EMAIL PROTECTED]>
To: "mysql" <[EMAIL PROTECTED]>
Sent: Friday, July 20, 2001 9:53 PM
Subject: auto_increment, is this a bug?? Where to report it?


> Hello guys...
>
>  I'm having problem with the auto_increment feature.
>  I have a table like this...
>
>
+--------+-----------------+------+-----+------------+----------------+
>   | Field  | Type            | Null | Key | Default    | Extra
> |
>
>
+--------+-----------------+------+-----+------------+----------------+
>   | Data   | date            |      |     | 0000-00-00 |
> |
>   | Edicao | int(3) unsigned |      | PRI | NULL       |
auto_increment
> |
>   | Status | varchar(6)      |      |     |            |
> |
>
>
+--------+-----------------+------+-----+------------+----------------+
>
>  When I make entries to this table, the column Edition goes...
>   +--------+
>   | Edicao |
>   +--------+
>   |      1 |
>   |      2 |
>   |      3 |
>   +--------+
>  as expected.
>  The problem is...if I delete the third entry (Edicao = 3), the next
> entry inserted should be 3, right?! Well it is not! It is 4. So I get
a
> table like this...
>   +--------+
>   | Edicao |
>   +--------+
>   |      1 |
>   |      2 |
>   |      4 |
>   +--------+
>
>  Well, I tested it on 2.33.37, 2.33.38 and 2.33.39. In 2.33.37 it was
> right...the entry was 3. But in the newer versions the number was 4.
> It's like the auto_increment pointer didn't do the decrement when I
> deleted the last entry.
>  Is this a bug?! Where should it be reported to?
>  Thank you all...
>
>  William N. Zanatta
>
> ---------------------------------------------------------------------
> 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
>


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