By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE test (Id INT, Note TEXT, Client VARCHAR(128))
SELECT 1 Id, 'Long note that have
multiple lines
Client: Name-1' Note, NULL Client
UNION ALL
SELECT 2, 'Anoter note that have multiple lines
Customer: Name-2', NULL
UNION ALL
SELECT 3, 'Third note that have multiple lines
Client : Name-3
line', NULL
UNION ALL
SELECT 4, 'Line: A
Client : Name-4
line', NULL
UNION ALL
SELECT 5, 'Line B
B : Line
Customer : Name-5
line
others', NULL;
SELECT * FROM test;
Records: 5 Duplicates: 0 Warnings: 0
Id | Note | Client |
---|---|---|
1 | Long note that have multiple lines Client: Name-1 |
null |
2 | Anoter note that have multiple lines Customer: Name-2 |
null |
3 | Third note that have multiple lines Client : Name-3 line |
null |
4 | Line: A Client : Name-4 line |
null |
5 | Line B B : Line Customer : Name-5 line others |
null |
UPDATE test
SET Client = SUBSTRING_INDEX(SUBSTRING_INDEX(Note, ': ', -1), CHAR(10), 1);
SELECT * FROM test;
Rows matched: 5 Changed: 5 Warnings: 0
Id | Note | Client |
---|---|---|
1 | Long note that have multiple lines Client: Name-1 |
Name-1 |
2 | Anoter note that have multiple lines Customer: Name-2 |
Name-2 |
3 | Third note that have multiple lines Client : Name-3 line |
Name-3 |
4 | Line: A Client : Name-4 line |
Name-4 |
5 | Line B B : Line Customer : Name-5 line others |
Name-5 |