SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Jan 2005
    Location
    ireland
    Posts
    482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Auto-Increment Problem

    In the table you can see below I have an auto-increment value I use as my primary key, currently it increments starting at 1,2,3 and so on is there anyway that I can make it go FG01,FG02,FG03 on so on. I mean can the auto-increment value be set to a value of your choice

    CREATE TABLE `grind_record` (
    `grind_record_id` mediumint(8) unsigned NOT NULL auto_increment,
    `user_id` mediumint(8) unsigned NOT NULL default '0',
    `secondary_exam_id` tinyint(2) unsigned NOT NULL default '0',
    `subject_id` tinyint(2) unsigned NOT NULL default '0',
    `secondary_level_id` tinyint(2) unsigned NOT NULL default '0',
    PRIMARY KEY (`grind_record_id`),
    KEY `user_id` (`user_id`,`secondary_exam_id`,`subject_id`,`secondary_level_id`)
    ) TYPE=InnoDB COMMENT='Grind Records' AUTO_INCREMENT=61 ;

    TKs

  2. #2
    Non-Member DaveMichaels's Avatar
    Join Date
    Nov 2004
    Location
    US
    Posts
    535
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No it can't - int's only.

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    you can achieve a similar result by appending the auto_increment value to a constant every time you want to display the key, but this is not recommended, and you should not need to display your key in the first place
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •