I want to show one custom column as alias but need to increment by using auto character.
id subid dollar packetname
168 355 5813 ND-1
169 355 359 ND-1
170 356 559 ND-2
171 362 4536 ND-10
172 362 484 ND-10
134 329 4698 ND-12
135 329 435 ND-12
125 330 6293 ND-13
126 330 4293 ND-13
127 330 693 ND-13
I need a output with another updated packet. column with autoincrement character
id subid dollar packetname updated packet
168 355 5813 ND-1 ND-1
169 355 359 ND-1 ND-1A
170 356 559 ND-2 ND-2
171 362 4536 ND-10 ND-10
172 362 484 ND-10 ND-10A
134 329 4698 ND-12 ND-12
135 329 435 ND-12 ND-12A
125 330 6293 ND-13 ND-13
126 330 4293 ND-13 ND-13A
127 330 693 ND-13 ND-13B
1 Create auto increment column in SharePoint list using SharePoint designer workflow. 2 Auto generate SharePoint list column using Calculated field. 3 Create auto increment column in SharePoint list using Event Receivers. 4 Create auto increment column in SharePoint list using Microsoft Flow.
I think there is no need to maintain the Auto Increment Id with Characters & integers. Simply create an Identity Column in your table which should be increment by 1. You will get the required output. Try above. Hope this will help you.
Syntax for MySQL. The following SQL statement defines the "Personid" column to be an auto-increment primary key field in the "Persons" table: MySQL uses the AUTO_INCREMENT keyword to perform an auto-increment feature. By default, the starting value for AUTO_INCREMENT is 1, and it will increment by 1 for each new record.
Syntax for SQL Server. The following SQL statement defines the "Personid" column to be an auto-increment primary key field in the "Persons" table: ); The MS SQL Server uses the IDENTITY keyword to perform an auto-increment feature. In the example above, the starting value for IDENTITY is 1, and it will increment by 1 for each new record.
You can use such query to make additional field
SELECT concat(packetname,
elt(if(@t=packetname, @n:=@n+1, @n:=1),
'','A','B','C','D','E','F','G')) `updated packet`,
id, subid, dollar, @t:=packetname packetname
FROM t
cross join
(SELECT @n:=1, @t:="") n
order by packetname
demo on sqlfiddle
I think your best bet is to SELECT
out the current packet table, modifying it along the way, and INSERT
it into a new table. Once you have completed this operation, you can drop the original table, and then rename the new one to the old one.
INSERT INTO newpacket (id, subid, dollar, packetname, `updated packet`)
SELECT p1.id, p1.subid, p1.dollar, p1.packetname, p2.`updated packet`
FROM packet p1
INNER JOIN
(
SELECT p.id, p.subid,
CASE WHEN (SELECT p.id - MIN(t.id) FROM packet t WHERE t.subid = p.subid) > 0
THEN CONCAT(packetname,
CHAR(((SELECT p.id - MIN(t.id) FROM packet t WHERE t.subid = p.subid) + 64) USING utf8))
ELSE packetname END AS `updated packet`
FROM packet p
) p2
ON p1.subid = p2.subid AND p1.id = p2.id
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With