Reputation:
I Have Two SQL Table's Columns
Is there any way which only transfer 410015,
From 410015,410016,410017,410018,410019,410020
(which is Column A Value) To Column B using PHP. So the values will look like
410016,410017,410018,410019,410020
410015,
Please Help!!! Thanks.
Upvotes: 1
Views: 77
Reputation:
I tried REPLACE & CONCAT_WS and it works.
UPDATE Table SET ColumnA = REPLACE(ColumnA , '410015', '') WHERE ColumnA LIKE '%410015%';
UPDATE Table SET ColumnB = CONCAT_WS(',', ColumnB, '410015')
Upvotes: 1
Reputation: 5598
If you want you can do it via SQL:
UPDATE Table
SET ColumnB = SUBSTRING(ColumnA, 1, LOCATE(ColumnA, ','))
WHERE LOCATE(ColumnA, ',') > 0 AND
ColumnA LIKE '%410015%'
Upvotes: 1