Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8356365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:10:35+00:00 2026-06-09T10:10:35+00:00

I have numbers saved as VARCHAR to a MySQL database. I can not make

  • 0

I have numbers saved as VARCHAR to a MySQL database. I can not make them INT due to some other depending circumstances.

It is taking them as character not as number while sorting.

In database I have

1 2 3 4 5 6 7 8 9 10...

On my page it shows ordered list like this:

1 10 2 3 4 5 6 7 8 9

How can I make it appear ordered by numbers ascending?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T10:10:36+00:00Added an answer on June 9, 2026 at 10:10 am

    If possible you should change the data type of the column to a number if you only store numbers anyway.

    If you can’t do that then cast your column value to an integer explicitly with

    select col from yourtable
    order by cast(col as unsigned)
    

    or implicitly for instance with a mathematical operation which forces a conversion to number

    select col from yourtable
    order by col + 0
    

    BTW MySQL converts strings from left to right. Examples:

    string value  |  integer value after conversion
    --------------+--------------------------------
    '1'           |  1
    'ABC'         |  0   /* the string does not contain a number, so the result is 0 */
    '123miles'    |  123 
    '$123'        |  0   /* the left side of the string does not start with a number */
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have php mysql application and i want the phone numbers be saved in
I have some numbers stored in a std::vector<int> . I want to find which
I have a field in my database where users have saved free-form telephone numbers.
If I have a Visa card number saved in my database, is there a
I have numbers in javascript from 01(int) to 09(int) and I want add 1(int)
Using for loop in PHP can we have numbers associate with a variable name?
I have 2 numbers which are between 0 and 49. Let's call them x
I have a PHP form that when submitted saves to a MySQL database. One
I have a loop that successfully shows account numbers. Some of these numbers were
I have several different input files, saved with case numbers .1, .2, etc to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.