Reputation: 110257
I have the following update statement:
UPDATE home_isilonpath
SET path_end = SUBSTRING_INDEX(path, '/', -1)
WHERE id > 1512647
Unfortunately, I am unable to change the length of my column for path_end
. How would I update the query to truncate the result at 200 char?
Upvotes: 0
Views: 81
Reputation: 13107
Try:
UPDATE home_isilonpath
SET path_end = SUBSTRING(SUBSTRING_INDEX(path, '/', -1), 0, 200)
WHERE id > 1512647
or, as proposed by tadman:
UPDATE home_isilonpath
SET path_end = LEFT(SUBSTRING_INDEX(path, '/', -1), 200)
WHERE id > 1512647
Upvotes: 1