Use the ORDER BY clause in a foreign language field

I have the name of some countries in different languages ​​in the MySQL db table, the table can support utf8. But SELECT * FROM countries ORDER BY 'name_czech' always sorts the English alphabetical order

enter image description here

enter image description here

My question is: how can we sort entries by foreign language field?

+7
source share
3 answers

maybe you want to use a backlink instead of a single quote

 SELECT * FROM countries ORDER BY `name_czech` 
+1
source

I do not quite understand the question or what you want to achieve, but I can guess from the pattern that you give that the ordering is not performed, except for the default mysql order. To be able to order by column, you want to use backtick characters (`). In some conditions, "character" is also allowed, although I doubt what you need.

Returning to the sorting problem, if the column name means anything, then I think these are names in Czech. The important thing is that sorting has a column. If it is utf8 sorting, then sorting will be carried out in accordance with this. If not, you can always force a match other than the one you defined for the column using ORDER BY name_czech COLLATE utf8_czech_ci , which will apply sorting to the appropriate sort. If the column is utf8, you should have no more surprises.

Basically, this either returns a sort change for the column if it is not suitable (according to the alter table), or change the sort during the query.

+1
source

got it, I just delete the single value of the field name

 select * from countries order by name_czech 

Thanks to all my friends.

0
source

All Articles