MySQL Forums
Forum List  »  Newbie

Re: Populating tables
Posted by: Barry Galbraith
Date: March 23, 2013 08:50PM

>CID001

Are you limiting yourself to 999 customers?
You could define you table with

CREATE TABLE mytable (
id int(3) auto_increment not null zerofill primary index,
-- other columns ...
...
);

INSERT without specifying the cid, and you'll get the next id.

Then when you SELECT id from mytable do this

SELECT CONCAT('CID',id) cid from mytable ....;

and you'll get CID001, CID002, etc

Good luck,
Barry.

Options: ReplyQuote


Subject
Written By
Posted
March 22, 2013 05:03PM
March 22, 2013 09:00PM
March 23, 2013 01:10PM
Re: Populating tables
March 23, 2013 08:50PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.