Skip to content

Instantly share code, notes, and snippets.

@ArneAnka
Created July 29, 2020 06:14
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 ArneAnka/1bf5b39cfd208e7c10caf28d17f416cb to your computer and use it in GitHub Desktop.
Save ArneAnka/1bf5b39cfd208e7c10caf28d17f416cb to your computer and use it in GitHub Desktop.
Move "The" to the end of a column
UPDATE games
SET title = CASE WHEN INSTR(title,' ')>0
AND LEFT(title,INSTR(title,' '))
IN ('The ')
THEN CONCAT(UPPER(SUBSTRING(title,INSTR(title,' ')+1,1))
,SUBSTRING(title,INSTR(title,' ')+2)
, ', '
, LEFT(title,INSTR(title,' ')-1))
ELSE title
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment