Order by command with Sqlite accent

Asked

Viewed 396 times

6

I am programming for Android and using the native database(SQLite). I want to make a query in the product table ordered by name, but while doing the SELECT thus:

SELECT * FROM produtos ORDER BY nome;

it returns, for example:

Alvejante
Cloro
Sabão Liquido
Água Sanitária

I want the SELECT ignore the score and get the following return:

Água Sanitária
Alvejante
Cloro
Sabão Liquido

It is possible to do this?

  • 1

    Try it straight like this: ...ORDER BY nome COLLATE utf8_general_ci;. If it doesn’t work, try to change the LEOTARD from the bank to what I put in the query.

  • was testing this solution.. knew it worked on where, I went to validate at order by.. =p

  • I tried your solution Diego, but Android Studio claimed "no such collation Sequence: utf8_general_ci", anyway, thank you.

1 answer

6


In this case you can use, one of these two:

(SUA QUERY) ORDER BY NOME COLLATE UNICODE

(SUA QUERY) ORDER BY NOME COLLATE LOCALIZED

Follow the reference of the documentation:

Localized Collation - ORDER BY In addition to Sqlite’s default BINARY collator, Android Supplies two more, LOCALIZED, which changes with the system’s Current locale, and UNICODE, which is the Unicode Collation Algorithm and not tailored to the Current locale. LINK

  • Translation:

Localized grouping - ORDER BY Beyond the BINARY standard of collator of the Sqlite, Android provides two more, LOCALIZED, that changes with the current location of the system and UNICODE, which is the algorithm Unicode Collation and not adapted to the current location.

  • 1

    It worked perfectly with UNICODE. Thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.