Skip to content

Instantly share code, notes, and snippets.

@nwingt
Last active May 11, 2017 07:30
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 nwingt/b24a185be8b988f1516d9ad595293db6 to your computer and use it in GitHub Desktop.
Save nwingt/b24a185be8b988f1516d9ad595293db6 to your computer and use it in GitHub Desktop.
oice_SQL_snippet

Sort Character FG Images

Replace the {CHARACTER_ID} by the character id you want to order

SELECT A.id, 
       A.`name_en`
FROM   `asset` AS A 
       JOIN `character_fgimages` CA 
         ON CA.`asset_id` = A.`id` 
WHERE  CA.`character_id` = {CHARACTER_ID} 
       AND A.`is_deleted` = false 
ORDER BY A.`order` 
  1. Copy the query result from the above SQL to Sublime Text
  2. Find: ([0-9]+)(\t.*)
  3. Sort the line manually (Mac: ctrl + cmd + ↑ OR ↓, Window: ctrl + shift + ↑ OR ↓)
  4. Replace: UPDATE `asset` SET `order` = {order} WHERE `id` = $1;
  5. Select all {order}
  6. Use Text-Pastry to adding 1 for each selection (\i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment