Add custom Code in Mysql Table Column Using Query

14 Apr

if you face problem like that then this code very helpful for you and save your lot of time.

Example: if you want to add Table Unique code after data Enter and you want to inter unique code in sequence with custom code type then use this way.i added image for your help to understand.

After Alter to add new Column with the name of locationCode then you first run this query for number sequence

SET@rank:=0;update T
set Number=@rank:=@rank+1

My Code:

SET @rank:=0;
update location
set LocationCode=@rank:=@rank+1

After Execute this code table column appear Value in Number sequence.if you set custom code type then..

UPDATE Table SET Column= Concat('0', Column);


update location
set LocationCode=Concat('LOC-', LocationCode)

Add custom Secuance With Query



Leave a comment

Posted by on April 14, 2014 in My SQL


Tags: ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: