Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2002
    Posts
    5

    Unanswered: Ignoring in (ORDER BY)

    Hi,

    Is there a way to ignore some alphabet when ordering names by ASC or DESC

    A sample :

    I have a table (first_name) :

    - The test.
    - Falcon
    - The Armageddon
    - Battle


    When ordering it will be :

    Battle
    Falcon
    The Armageddon
    The test.



    is there a command that ignore (The) in the order, so it will be :

    The Armageddon
    Battle
    Falcon
    The test.


    ?

  2. #2
    Join Date
    Feb 2001
    Location
    NC, USA
    Posts
    200
    Use the SUBSTRING function in the order by clause. ie.
    Code:
    SELECT title, description
       FROM mytable
       ORDER BY SUBSTRING(title,5);
    This will only use letters starting at position 5.

    MySQL has quite a good selection of string functions. There are probably other ways to this. See here

  3. #3
    Join Date
    Feb 2002
    Posts
    5
    thanks

    it works with english alphabet,

    but it dosn't work with arabic alphabet

  4. #4
    Join Date
    Dec 2001
    Location
    Toronto, Canada
    Posts
    335
    Actually the solution that Paul gave works for that example, since the 5th character of each word does place the word in order:

    l - Battle
    o - Falcon
    a - The Armageddon
    t - The test

    Reordered

    a - The Armageddon
    l - Battle
    o - Falcon
    t - The test

    This code will work without having to figure out which position should you ORDER BY.
    Code:
    select * from tbl order by REPLACE(col1,"The ","");

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •