473,396 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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!!
May 11 '09 #1
6 2068
r035198x
13,262 8TB
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.
May 11 '09 #2
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.
May 11 '09 #3
r035198x
13,262 8TB
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.
May 11 '09 #4
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 :)
May 12 '09 #5
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
May 13 '09 #6
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.
May 13 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Paul Lamonby | last post by:
Hi, i want to create a unique serial number to my Db entries. I thought the best way would be to add the auto_increment primary key value to a string, then insert it into a table field...
4
by: Pjotr Wedersteers | last post by:
I have a table with quiz questions. Each question has a unique ID, based on an auto_increment field. Now I've discovered that with deleting rows from the table the deleted ID's are not reissued....
2
by: Ittay Freiman | last post by:
i cannot set auto_increment to start from anything other than 1: mysql> create table test (id int unsigned not null auto_increment primary key); mysql> alter table test auto_increment=2; ...
2
by: Nico v. Rossum | last post by:
Hi * How can reset a auto_incremet collumn so it starts from 1 TIA
9
by: Bart Van der Donck | last post by:
Hello, The first column of my table is AUTO_INCREMENT. I fill my table with 5 records with a blanco value in their first field. The first column of my table will then hold the values 1,2,3,4,5...
0
by: Shailesh | last post by:
I made a MyISAM table on mysql 4.0.18 NT with auto_increment column started at 2147483646. The third row I insert fails as expected because the integer range is maxed out. However, if I delete...
2
by: hjyn | last post by:
Hi, how can I add char to auto_increment? For example, the auto_increment is for integer, I want to add a character at the front of that number. Ex: >create table abs (UserID INT(3) NOT NULL...
1
by: Phil Latio | last post by:
Newbie questions here... Reading the MySQL manual regarding InnoDB databases, can someone confirm that: 1. if the server is rebooted, AUTO_INCREMENT reverts back to 1? 2. what happens if the...
1
by: bcm | last post by:
I am migrating a database to MySQL 5.0. Several tables should have their primary key as an auto_increment integer. The database being copied has records with the primary key beginning with zero...
1
by: mostafijur | last post by:
Hello, My database table containing a column name P_ID Field Extra = P_ID, Type = int(11), Null = NO, Key = PRI, Default = NULL, Extra = auto_increment
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.