Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Which Data Type To Use In Mysql Table, Using a 5 character number
mrdee
post Nov 1 2007, 10:50 PM
Post #1


Super Member
*********

Group: [HOSTED]
Posts: 258
Joined: 18-July 07
From: Slough (UK)
Member No.: 46,682



If I wanted to use an ID field which automatically increments when data are addad, but displays the ID as a 5 figure number, which data type would I have to use?
I would want a type that assigns a number to a record in the format "00001", "00002", etc.
However, when I use "int" as datatype, it only displays th field contents as "1", "2" etc.
So, which data type could do the job for me?
i do not need a decimal point or anything, just an id that displays in 5 figures, including the leading zeros.
Thanks in advance.
Go to the top of the page
 
+Quote Post
jlhaslip
post Nov 1 2007, 11:40 PM
Post #2


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,882
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



here: http://www.ilovejackdaniels.com/cheat-shee...ql-cheat-sheet/ keep that handy while you move along.

What you may need to do is define the ID as an INT value for the purpose of being an index, but cast it as a String value and pad the left side with zeroes when you display or print it. Strings don't make the best Index values.

Check this: http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html

Especially the comments about ZEROFILL under that first Table.

Unsigned smallint is good for 64K values. that is a whole bunch of students. And define it as auto-increment.
Go to the top of the page
 
+Quote Post
mrdee
post Nov 2 2007, 12:28 AM
Post #3


Super Member
*********

Group: [HOSTED]
Posts: 258
Joined: 18-July 07
From: Slough (UK)
Member No.: 46,682



You see,
the intention is to generate like a customer number for them, a sort of customer ID, such as an ID to be printed on invoices.
Also good as recognition or to look them up in the database.
Eg. 00023= Mr. John Smith, 00038=Mrs. Sally Jones.

Or else, a way to auto generate something like:
(For piano students) PI00023
(For singing students) SI00038
(For keyboard students) KE00057

Get my drift?

That is, of course, difficult to do for me as a beginner, hence the, what probably looks to some reafers her like, moronic questions.

All help is very much appreciated and gratefully accepted, though.
Go to the top of the page
 
+Quote Post
jlhaslip
post Nov 2 2007, 03:34 AM
Post #4


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,882
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



There are no stupid questions if you learn something from the answer.

Even if all you learn is that the respondent doesn't know anything.

Anyways, as a suggestion based on the experience I have had, you would be better off not including the alphabetic indicator on those customer id's.

What happens if a student quits being a singing student and want lessons on the piano? start a different number with a 'P'?
Nope, one student, one number. Let the Income side determine the source of revenue for you and indicate the type of student they are.

Believe me, trying to 'code' a stack of numbers is a nightmarish experience. I did it once for a Construction Company that owned several thousand pieces and types of equipment, like a rental Company... yuck! Drove us nuts. They wanted to identify the difference between trucks that had a radio and those that did not have one: into an 8 digit number and make them all signifigant... Nightmare experience.
Go to the top of the page
 
+Quote Post
mrdee
post Nov 2 2007, 04:17 AM
Post #5


Super Member
*********

Group: [HOSTED]
Posts: 258
Joined: 18-July 07
From: Slough (UK)
Member No.: 46,682



True really.
That, as you say, would probably complicate things needlessly.
It was only like a thing of me getting carried away really.
Thanks for the advice.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Mysql Infos(2)
  2. Mysql Tool(0)
  3. Mysql And Ms Access(1)
  4. What If You Forget Mysql Root Password(2)
  5. Mysql Host Adress(4)
  6. Import From Excel File Into Mysql Database(7)
  7. Php And Mysql Problem(8)
  8. Tips On Creating Your Own Search(1)
  9. Syndicate Your Content Using Php And Mysql(0)
  10. Phpbb And Mysql Relations?(2)
  11. How Do You Combine Multiple Mysql Databases Into One Database?(3)
  12. Help Or Advise Needed For Access Database Webpage Conversions(0)
  13. Merging Database Php Mysql(5)
  14. Where Am I Going Wrong This Time?(4)
  15. Another Question On Mysql Table Data Type(1)
  1. Accessing Mysql From Javascript(4)
  2. Mysql + Php Question(5)
  3. Treating .csv Files As Database Data(2)
  4. Index In A Mysql Database(3)
  5. Mysql(2)
  6. Need Help With My Database [resolved](6)


 



- Lo-Fi Version Time is now: 25th July 2008 - 11:38 PM