i want to generate A0001 as user id in php. i tried a lot for this but i can't did that so anybody here to help me.........
ipradip 0 Light Poster
Recommended Answers
Jump to Postsample
select concat('A',lpad(MAX(substr('A0001',2))+1,4,'0')) new_numberfrom table here pkcolname is your primary key of table with first is letter and rest 4 are numbers.
select concat('A',lpad(MAX(substr(pkcolname,2))+1,4,'0')) new_number FROM TABLENAME
Jump to PostLet mysql do it for you. Just use a PK BIGINT(20) AUTOINC (id) field, and add a calculated field to transform it into your id. CONCAT('A', LPAD(CAST(id AS VARCHAR)), 4, '0')
All 7 Replies
urtrivedi 276 Nearly a Posting Virtuoso
tiggsy 4 Junior Poster
ipradip 0 Light Poster
urtrivedi 276 Nearly a Posting Virtuoso
tiggsy 4 Junior Poster
pritaeas 2,211 ¯\_(ツ)_/¯ Moderator Featured Poster
ipradip 0 Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.