List:General Discussion« Previous MessageNext Message »
From:Frederic Wenzel Date:January 23 2004 2:09pm
Subject:Re: Order by problem
View as plain text  
Sagar C Nannapaneni wrote:
> ASS1
> ASS23
> ASS4
> ASS10
> ASS6
> .
> .
> 
> when i'm retrieving the data by taking ORDER BY clause it is sorting like this
> 
> ASS1
> ASS10
> ASS23
> ASS4
> ASS6
> 
> means its only sorting by the 4 the character.

No, it's not sorted by the first four characters but it's sorted 
lexicographically (string-like).

The following might help, but will certainly be quite slow:

SELECT ... ORDER BY ABS(SUBSTRING(field, 4));

A better (and faster) solution will probably be indexing the records 
with a numeric field, as usual.

Greetz
Fred
Thread
Order by problemSagar C Nannapaneni23 Jan
  • Re: Order by problemMartijn Tonies23 Jan
  • Re: Order by problemBenoit St-Jean23 Jan
  • Re: Order by problemFrederic Wenzel23 Jan
    • SELECT statementGary Broughton23 Jan
    • Re: Order by problemmos23 Jan
  • Re: Order by problemmos23 Jan