Skip to content

Instantly share code, notes, and snippets.

@tikaszvince
Created June 26, 2014 16:14
Show Gist options
  • Save tikaszvince/611a6566a0b61107fd9a to your computer and use it in GitHub Desktop.
Save tikaszvince/611a6566a0b61107fd9a to your computer and use it in GitHub Desktop.
SELECT
id, name
FROM
names
order by
FIELD(
(
CASE 1
WHEN SUBSTRING(BINARY name 1, 3) = 'Dzs'
THEN 'Dzs'
WHEN SUBSTRING(BINARY name, 1, 2) IN ('Cs', 'Dz', 'Gy', 'Ly', 'Ny', 'Sz', 'Ty', 'Zs')
THEN SUBSTRING(BINARY name, 1, 2)
ELSE SUBSTRING(name, 1, 1) END
),
'A','Á','B', 'C','Cs','D','Dz', 'Dzs', 'E','É','F','G', 'Gy',
'H','I','Í','J','K','L', 'Ly','M','N', 'Ny','O','Ó','Ö','Ő',
'P','Q','R','S', 'Sz','T', 'Ty','U','Ú','Ü','Ű','V','W','X',
'Y','Z', 'Zs'
) ASC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment