MySQL Order by String Language

I have a large table in a database with tags. Not all words have Latin characters (English, French ...), some words have non-Latin characters (Hebrew, Persian, Arabic ...)

How to choose words ORDER BY [Language of word]?

+5
source share
2 answers

You can define a second table language, and then attach a language tag to each record. You can add the sort order column to the language table, then when you select, connect to the language table and order by tag field, then by language sort order.

+4
source

You can use a mysql function called FIELD ()

ORDER BY FIELD(Language,'English','Japan','Swedish')

OR if you have fewer languages ​​to order:

ORDER BY `ID`,
     CASE `Language`
     WHEN 'English' THEN 1
     WHEN 'Japenese' THEN 2
     WHEN 'Swedish' THEN 3
     END
+1
source

All Articles