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

  • SEARCH
  • Home
  • 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 902033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:39:11+00:00 2026-05-15T15:39:11+00:00

How do you order by number if your number can fall below and be

  • 0

How do you order by number if your number can fall below and be bigger than 0?

Example Mysql table:

|Name|Karma|
 __________
|Me  | -8  |
|Bill|  5  |
|Tom |  2  |
|Saly|  0  |
|San.| -3  |

Example select query

$sql="SELECT karma FROM table ORDER BY karma DESC";

The result I get is this (separated by comma): 5,2,0,-8,-3.
Shouldn’t it be 5,2,0,-3,-8?
I discovered somewhere in the internet that mysql orders by string. How to make it order by number?

  • 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-05-15T15:39:12+00:00Added an answer on May 15, 2026 at 3:39 pm

    Karma will be ordered as a string if you have made it a string, i.e. a varchar column.

    Convert the column to a INT, and it will order numerically.

    You also have the option of not changing the table, but casting the column into the right type while sorting:

    SELECT karma FROM table ORDER BY CAST(karma AS int) DESC
    

    but that is bad for performance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to make my table can filtering in each column. i get client
I need to use the MySQL Order By function in a query except I
In order to create an Apple developer account: Is it necessary to enter name
I have the following locations table: ---------------------------------------------------------- | ID | zoneID | storeID |
As I noticed in the answers of another question there are a few problems
I have read some tutorials for bezier curve such as this one http://www.codeproject.com/KB/recipes/BezirCurves.aspx .
I'm not even sure if this is possible or not, but here's what I'd
I have trouble getting started with rails 3.0.0, because it just doesn't load the
I would like to compare two collections (in C#), but I'm not sure of
The answers to a previous question pointed out that the keywords meta tag in

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.