PravinCG
PravinCG

Reputation: 7708

SQLite Sorting TEXT field

I have the following table:

CREATE TABLE IF NOT EXISTS TEST_TABLE ( testID INTEGER PRIMARY KEY AUTOINCREMENT, testName TEXT);

Some of the test data

  1. Test
  2. Hello
  3. aa
  4. World

My Query

SELECT * FROM TEST_TABLE ORDER BY testName

Response:

  1. Hello
  2. Test
  3. World
  4. aa

Expected:

  1. aa
  2. Hello
  3. Test
  4. World

Can someone explain why this is the response?

Upvotes: 0

Views: 894

Answers (2)

iGranDav
iGranDav

Reputation: 2460

That's because ORDER BY is case sensitive and a 'a' is greater than a 'Z'. There is a solution to be case insensitive : [Your request] ORDER BY testName COLLATE NOCASE

Hope this could explain your problem.

Edit : dom explain it before :-)

Upvotes: 4

dom
dom

Reputation: 661

try this:

SELECT * FROM TEST_TABLE ORDER BY testName COLLATE NOCASE;

Upvotes: 5

Related Questions