Jump to content

[SOLVED] MYSQL not reading - and + plus numbers correctly


Recommended Posts

Hi.

 

I have a little league table integrated at www.afc-chat.co.uk

 

It doesnt seem to the rows in the right order.

 

MySQL is

SELECT * FROM leaguetable ORDER BY points DESC, gd DESC

 

As you will see i want the data ordered by points then by goal difference (gd). I have tried both ASC and DESC and they work when the numbers invert by being either positive or negative, but changing that manually obviously isnt the right way to do things.

 

The database is entered into the database by a single field like: "+10" or "-4". Maybe its the input i need to change?

 

Any help greatly appreciated.

 

JM.

 

 

What data type are those columns?  If they are varchar or char then you will need to convert them to integers each time you order, which can be done like this:

 

SELECT * from leaguetable ORDER BY point + 0 DESC, gd + 0 DESC

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.