Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL Order by language of string

Tags:

php

mysql

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

How can I select the words ORDER BY [Language of word] ?

like image 542
S.B. Avatar asked Feb 28 '13 23:02

S.B.


People also ask

How to order by specific strings in MySQL?

MySQL Order By specific strings? Order by the choice of strings you want, using the FIELD () function. The syntax is as follows − SELECT *FROM yourTableName ORDER BY FIELD (yourColumnName,’yourValue1’, ’yourValue2’,’yourValue3’,....N);

How to sort data using a custom list in MySQL?

The ORDER BY clause allows you to sort data using a custom list by using the FIELD () function. See the following orders table from the sample database. Suppose that you want to sort the sales orders based on their statuses in the following order:

How to use ORDER BY clause in MySQL for natural sorting?

Summary: in this tutorial, you will learn about some natural sorting techniques in MySQL using the ORDER BY clause. First, create a new table named items by using the following CREATE TABLE statement: Third, query data from the items table sorted by the item_no: This may not what we expected. We expect to see the result like the following picture:

How to sort values in MySQL in ascending or descending order?

We are used to sort both numeric and string values either in ascending or descending manner. But by default, it sorts in ascending manner. If we want to descend, then we need to specify it after using the ORDER BY clause.


1 Answers

You could define a second table languages, then attach a language tag to each entry. You can add a sort order column to the languages table, then when you select, join against the languages table and order by the tag field, then by the language sort order.

like image 120
Zak Avatar answered Sep 20 '22 01:09

Zak