Trim unwanted text with start and end index in column Trim unwanted text with start and end index in column wordpress wordpress

Trim unwanted text with start and end index in column


mysql> SELECT SUBSTRING_INDEX('/articles/2013/02/27/time-for-land-audit', '/', -1) AS short_url;+---------------------+| short_url           |+---------------------+| time-for-land-audit |+---------------------+

As an UPDATE it would look like this:

UPDATE mytable SET url = SUBSTRING_INDEX(url, '/', -1)

See https://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_substring-index for documentation.

P.S.: Be sure to test that this does what you want on a test sample of the data first! You wouldn't want to be surprised and find that you had ruined your sole copy of the data.


Please put your table name at the place of "Yourtable" and run below command.

UPDATE YourTable SET url=Replace(Reverse(substring(reverse(url),0,charindex('/',reverse(url)))),'**','')

I have just check it in select statement ,it will definitely work for you.Please check snapshot for you reference.

enter image description here