add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
select version();
version()
8.4.3
CREATE TABLE posts (
post_title VARCHAR(255),
post_name VARCHAR(255)
);

INSERT INTO posts VALUES
('Title', 'ashgt-36548'),
('Some title', 'ahrgz-46587'),
('Some other title', 'kkahe-55486');

Records: 3  Duplicates: 0  Warnings: 0
SELECT * FROM posts;
post_title post_name
Title ashgt-36548
Some title ahrgz-46587
Some other title kkahe-55486
SELECT post_name, SUBSTRING(post_name,1,5) as newpost_name
FROM posts;
post_name newpost_name
ashgt-36548 ashgt
ahrgz-46587 ahrgz
kkahe-55486 kkahe
SELECT post_title,
SUBSTRING(post_name,7) ,
CONCAT('[',SUBSTRING(post_name,7),'] ',post_title) as newpost_title
FROM posts;
post_title SUBSTRING(post_name,7) newpost_title
Title 36548 [36548] Title
Some title 46587 [46587] Some title
Some other title 55486 [55486] Some other title
SELECT CONCAT('[',SUBSTRING(post_name,7),'] ',post_title) as post_title,
SUBSTRING(post_name,1,5) as newpost_name
FROM posts;
post_title newpost_name
[36548] Title ashgt
[46587] Some title ahrgz
[55486] Some other title kkahe
UPDATE posts
SET post_title = CONCAT('[',SUBSTRING(post_name,7),'] ',post_title) ,
post_name = SUBSTRING(post_name,1,5) ;
Rows matched: 3  Changed: 3  Warnings: 0
SELECT * FROM posts;
post_title post_name
[36548] Title ashgt
[46587] Some title ahrgz
[55486] Some other title kkahe