Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CrisHazzard/659f54ba4e4de30c665e24d5ce81e9dd to your computer and use it in GitHub Desktop.
Save CrisHazzard/659f54ba4e4de30c665e24d5ce81e9dd to your computer and use it in GitHub Desktop.
SQL Script to Remove leading directory from SQL field
UPDATE `table_name` SET `field_value` = SUBSTRING_INDEX(field_value, /', -1) WHERE `col_value` = 'col_match'
@CrisHazzard
Copy link
Author

I originally added subdirectories to my uploads directory for media to test for an SEO benefit, but there was none. I needed to remove the subdirectories from all the media for hikes all over the country that had different paths. This statement in PHYMyAdmin did the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment