#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0

    Order by for String numbers


    Hi,
    I am having following values in class_name column of the student table.
    5th,6th,7th,8th,9th,10th.

    But when I write following query:

    Code:
    select class_name from student order by class_name
    It returns as:
    10th
    5th
    6th
    7th
    8th
    9th

    But I want the O/P as below:

    5th
    6th
    7th
    8th
    9th
    10th

    Please help me.

    Thanks in Advance...!!
    Last edited by Guelphdad; October 12th, 2012 at 10:24 AM. Reason: swapped code for mysql in display
  2. #2
  3. Hockey face
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    St. Catharines, Canada
    Posts
    8,144
    Rep Power
    1316
    try this:
    Code:
    ORDER BY class_name + 0
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0

    Thanks


    Thanks Very much Guelphdad.
    It worked...

IMN logo majestic logo threadwatch logo seochat tools logo