PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > Custom AutoIncrement Field
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Custom AutoIncrement Field

Réponse
 
LinkBack Outils de la discussion
Vieux 18/04/2008, 19h31   #1
Fabio
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Custom AutoIncrement Field

How can I acomplish that?

I want a field in my table to autoincrement like 'CHD0001', 'CHD0002',
'CHD0003'

thanks!
  Réponse avec citation
Vieux 18/04/2008, 20h07   #2
Chuck
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Custom AutoIncrement Field

Fabio wrote:
> How can I acomplish that?
>
> I want a field in my table to autoincrement like 'CHD0001', 'CHD0002',
> 'CHD0003'
>
> thanks!


Why does the CHD prefix need to be there? Will it ever change?

If not it's unnecessary. It can be generated when you query the column
or with a view.

If yes, it should be a separate column.
  Réponse avec citation
Vieux 18/04/2008, 20h13   #3
Peter H. Coffin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Custom AutoIncrement Field

On Fri, 18 Apr 2008 11:31:54 -0700 (PDT), Fabio wrote:
> How can I acomplish that?
>
> I want a field in my table to autoincrement like 'CHD0001', 'CHD0002',
> 'CHD0003'


Can't do it straight. Can CONCAT('CHD', CAST(my_id as CHAR)) on select
though, where my_id is your autoincrement, zerofill int(5) column.

--
76. If the hero runs up to my roof, I will not run up after him and struggle
with him in an attempt to push him over the edge. I will also not engage
him at the edge of a cliff. (In the middle of a rope-bridge over a river
of molten lava is not even worth considering.) --Evil Overlord List
  Réponse avec citation
Vieux 18/04/2008, 20h39   #4
Erick T. Barkhuis
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Custom AutoIncrement Field

Chuck:
> Fabio wrote:
> >
> > I want a field in my table to autoincrement like 'CHD0001', 'CHD0002',
> > 'CHD0003'


> Why does the CHD prefix need to be there? Will it ever change?
>
> If not it's unnecessary. It can be generated when you query the column
> or with a view.


If CHD is there for presentational purposes only, I would prefer putting
it into the presentation (or logic) layer instead of using the database
to do that.

--
Erick
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 04h22.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,14748 seconds with 12 queries