Toon posts:

[mySQL] auto_increment INT 000

Pagina: 1
Acties:
  • 36 views sinds 30-01-2008

Verwijderd

Topicstarter
Beste Dames, Heren,

ik zit met iets waar ik niet geheel uit kom, vandaar mijn vraag hier.

Wat ik wil is een cel die begint bij 000 te tellen en dan doorgaat tot 999 etc. Zodra mySQL iets met 2 of 3 nullen ziet maakt ie er 1 nul van, hoe is dit op te lossen? Dat er 3 posities staan waarvan het begin in het begin een 0 is.

Verwijderd

Bij het uitlezen kun je toch wel zelf die twee voorloopnullen erbij zetten?

  • Sybr_E-N
  • Registratie: December 2001
  • Laatst online: 20-04 20:36
Volgens mij kan dat aan de hand van zerofill. Dus naast je kolom auto_increment maken ook nog zerofill toevoegen.
When used in conjunction with the optional extension attribute ZEROFILL, the default padding of spaces is replaced with zeros. For example, for a column declared as INT(5) ZEROFILL, a value of 4 is retrieved as 00004. Note that if you store larger values than the display width in an integer column, you may experience problems when MySQL generates temporary tables for some complicated joins, because in these cases MySQL trusts that the data did fit into the original column width.

[ Voor 59% gewijzigd door Sybr_E-N op 28-12-2005 12:19 ]


Verwijderd

Topicstarter
ja dat klopt, had inmiddels met google de juiste oplossing gevonden :) Bedankt allemaal.

  • NMe
  • Registratie: Februari 2004
  • Laatst online: 15-04 22:07

NMe

Quia Ego Sic Dico.

Beetje beter Googlen dus. ;)

Overigens is een database bedoeld voor opslag, niet voor formattering, dus het idee achter zerofill vind ik een beetje raar. Maar goed, dat is mijn persoonlijke mening. :P

'E's fighting in there!' he stuttered, grabbing the captain's arm.
'All by himself?' said the captain.
'No, with everyone!' shouted Nobby, hopping from one foot to the other.


Dit topic is gesloten.