1

how can I store number like this 000001 in mysql, and increment it everytime a new user register?

Nanne
  • 64,065
  • 16
  • 119
  • 163
yeah its me
  • 1,131
  • 4
  • 18
  • 27

2 Answers2

6

You can add zerofill to your (autoincrement) id column to do what the name suggests. It will make your datatype unsigned.

see also

Community
  • 1
  • 1
Nanne
  • 64,065
  • 16
  • 119
  • 163
2

Try adding ZEROFILL attribute to the field.

CREATE Table tableName (
   mykey int(6) zerofill not null auto_increment, 
   primary key(mykey)
);

will result every new record:

000001
John Woo
  • 258,903
  • 69
  • 498
  • 492