1

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

Nanne
  • 63,347
  • 16
  • 116
  • 159
yeah its me
  • 1,071
  • 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
  • 63,347
  • 16
  • 116
  • 159
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
  • 249,283
  • 65
  • 481
  • 481