If the integer value of the question number is not being used for sorting
then you can ensure a unique key value for each row by setting the column to
AUTO INCREMENT.

ALTER TABLE `questions_dbase`.`questions_table`
    CHANGE `questionnumber` `questionnumber`
    BIGINT(20)
    DEFAULT '0'
    NOT NULL
    AUTO_INCREMENT

Allow the field to auto increment by simply leaving the field blank in your
insert query.  Of course you can override the increment value by supplying
your own number but this is not recommended.

INSERT INTO `questions` (`questionnumber`) VALUES ('')

If your questionnumber field is being used for sorting purposes then I would
suggest some sort of script (PHP, PERL or ASP) to control the value.
-Kevin

----- Original Message -----
From: "bin cai" <[EMAIL PROTECTED]>
To: "mysql list" <[EMAIL PROTECTED]>
Sent: Friday, April 12, 2002 1:35 PM
Subject: auto update number in mysql


> Hello, verybody,
> currently i got one question.
> i create a table in mysql database to store questions
> which have following column fields: questionnumber,
> questionbody, answers and etc.
> My problem is if i delete one row(question) how can i
> update the questionnumber in the easiest way which
> means mysql can do for me. Is it possible? or i have
> to write a method to update questionnumber.
> Any help will be much appreciated.
> bin
>
> ______________________________________________________________________
> Music, Movies, Sports, Games! http://entertainment.yahoo.ca
>
> ---------------------------------------------------------------------
> 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