# [EMAIL PROTECTED] / 2003-06-16 21:09:14 +0200:
> In AUTO_INCREMENT fields, inserting a 0 into the field requests a new
> sequence number.
> 
> Is it possible to turn off this behaviour?

    I doubt that.

> (without messing with the code, of course)

    I doubt that some more.
 
> Using NULL to get the next sequence number is good enough for me and I use
> quite a lot 0 for special purposes (default record values,...)

    drop the auto_increment (and possible unique constraints) from the
    column in question so you'll be able to insert 0s, and

    CREATE TABLE seq (
        id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL,
        PRIMARY KEY (id)
    );
    INSERT seq VALUES (0);
    UPDATE seq set id = 0;

    now, when you need a new unique value, do:

    UPDATE seq SET id = LAST_INSERT_ID(id+1);
    SELECT LAST_INSERT_ID();

-- 
If you cc me or remove the list(s) completely I'll most likely ignore
your message.    see http://www.eyrie.org./~eagle/faqs/questions.html

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to