Jump to content

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


JohneeMac

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.