[This is an email copy of a Usenet post to "mailing.database.mysql"]
Just insert a row with the initial value you want minus one, and then
delete it. That will make the table do what you want.
mysql> INSERT INTO Orders VALUES (-1, "", NOW(), -1, 0000125478);
Query OK, 1 row affected (0.03 sec)
mysql> DELETE FROM Orders WHERE OrderNumber=125478;
Query OK, 1 row affected (0.02 sec)
mysql> INSERT INTO Orders VALUES (-1, "", NOW(), -1, 0);
Query OK, 1 row affected (0.02 sec)
mysql> SELECT LAST_INSERT_ID();
+------------------+
| last_insert_id() |
+------------------+
| 125479 |
+------------------+
1 row in set (0.02 sec)
--
Jeff S Wheeler [EMAIL PROTECTED]
Software Development Five Elements, Inc
http://www.five-elements.com/~jsw/
database sql query table
In article <9iqcs7$5n6$[EMAIL PROTECTED]>, "Bob"
<[EMAIL PROTECTED]> wrote:
> Hi,
> I'm a newbie to databases so please excuse my ignorance. How do I change
> the value of the OrderNumber column in this table? It currently starts
> at one (obviously). How do I get it so that it starts at 0000125478 or
> something?
>
> CREATE TABLE Orders (
> BuyerID BIGINT NOT NULL,
> UserID VARCHAR(100) NOT NULL,
> Date VARCHAR(100) NOT NULL,
> OrderTotal DECIMAL(8,2) NOT NULL,
> OrderNumber BIGINT NOT NULL AUTO_INCREMENT, PRIMARY KEY (OrderNumber)
> );
>
> thanks,
> BOB.
>
>
---------------------------------------------------------------------
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