Re: order desc problem

2006-07-09 Thread Chris Sansom

At 20:27 +0800 9/7/06, M & B Neretlis wrote:

the order comes out of sequence showing 10.11.12.13 etc before the number 2---
Can anyone help me out


 $query = @mysql_query("SELECT * FROM tips WHERE user_id = $user_id 
AND comp_id = $comp_id ORDER by round DESC");

 while ($result = @mysql_fetch_array($query)) {
 ?>


Coo - something I actually know!

What column type is round? I bet it's a varchar or some other 
non-numeric type. If I'm right, it's sorting lexically, so 1 comes 
before 11, comes before 2, etc.


Change it to a some flavour of int and it should work.

--
Cheers... Chris
Highway 57 Web Development -- http://highway57.co.uk/

But what ... is it good for?
   -- Engineer at the Advanced Computing Systems Division of IBM,
 commenting on the microchip, 1968

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: order desc problem

2006-07-09 Thread Aleksandar Bradaric
Hi,

> the order comes out of sequence showing 10.11.12.13 etc before the number 2---
> Can anyone help me out

That's  because  you  are  sorting  the  result  on a string
(char/varchar)  column.  Try  using  CAST  to  convert it to
int or something similar: ORDER BY cast(column as unsigned)


Best regards,
Aleksandar


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]