auto_increment

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AmiMitra
    New Member
    • Apr 2009
    • 24

    #1

    auto_increment

    i am designing a website for travel agency. the requirement is everytime any user books anything( car, hotel etc) a reservation id is generated for internal use. i want to start the resv_id with 'resv' and then a number following it. please tell me how to do it using auto_increment. is there any other way to do that? i have a table with attributes user_id ( created by the user) and resv_id ( generated) and the primary key is the composite key .please help.urgent!!
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    No need to store the 'resv' part in the database. It just add clutter. Just add the 'resv' part before you display the id to the users.

    Comment

    • AmiMitra
      New Member
      • Apr 2009
      • 24

      #3
      no this is not to display to the user. it will be saved in the database only. if it is not possible , then i would go for numeric data only.

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        If there is no need to display it then why should you worry about how it looks like?
        Pre pending that text just adds unnecessary characters to the database.

        Comment

        • AmiMitra
          New Member
          • Apr 2009
          • 24

          #5
          yes perhaps u r right. actually i was thinking as per the requirement documentation. but i also think choosing only the auto_increment function will do the work. thanx for consulting :)

          Comment

          • sandeepsandeep
            New Member
            • Dec 2006
            • 50

            #6
            Yes You can add prefix in Autoincrement..

            Make a CHAR (or VARCHAR) AUTO_INCREMENT column with mandatory
            PREFIX. MySQL would then assign values that start with the prefix,
            followed by a sequential number. The numbers could be chosen either
            from the whole INT set sequentially for all prefixes, or individually
            for each prefix, effectively multiplying the number of possible
            values - I don't really care about that. Example of proposed syntax:
            CREATE TABLE example2 (id VARCHAR(14) AUTO_INCREMENT PREFIX 'ISP',
            other_column VARCHAR(100));
            This would create id values of: 'ISP1', 'ISP2' etc.

            Regards,
            Sandeep Agarwal

            Comment

            • AmiMitra
              New Member
              • Apr 2009
              • 24

              #7
              yes i tried this one but it shows some error like
              incorrect column specifier for column 'id' , error no 1063.
              just for information , i m using mysql 5.1.

              Comment

              Working...