Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto increment, making the ID a varchar

Status
Not open for further replies.

TsukoJigger

Programmer
Dec 8, 2005
2
0
0
GB
Hi friendly Folks,

I was wondering if it's possible to customise the autoincrement function so that it will use a mixture of numerics and alpha numerics.

Basically I want the primary key's to be something like "row_[the incrememnting ID number]" not just the incrementing ID number.

I've had a trawl through the manual, but couldn't find anything.

Thanks for any and all help.

Jiggersaurus
 
Sure, I suppose it's possible to rewrite auto_increment...after all, MySQL's source code is available. But the default auto_increment feature of MySQL works only on integers.

If you need a static string prepended, do it in your SELECT query:

SELECT CONCAT('row_', the_id) AS string_id FROM tablname



Want the best answers? Ask the best questions! TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top