Starting number in MYSQL auto inc field

jonofat used Ask the Experts™
If someone inserts a record it starts at 1 and then every record there increases by one automatically so, 2, 3, 4 and so on. Is there a way to make it start at 17589 and then just auto inc from there ie: 17589 then next record will be 17590 and so on. If i try type 17589 as a default value for this column in the table it gives me an error and won't let me save it like that.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Insert a record with a manual number in the Auto Num column with the number before the next generated.



It is a primary key though and won't let me do that?

Or another option

Run the following query:
SET insert_id = 17589;
INSERT INTO tablename VALUES ('blah', '...');

This will add the next record into  as 17589.

The SET insert_id = #(where # is the next auto increment value you want to use) will reset the next auto increament value, the next query(INSERT) you run will use your choice of value.
ALTER TABLE `table_name` AUTO_INCREMENT =17589 

Open in new window

If you're using phpMyAdmin, you can open the table, select Operations from the tabs at the top, then insert the value into the box marked 'auto_increment'.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial