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!!
auto_increment
Collapse
X
-
-
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 AgarwalComment
Comment