Do you have a question? Post it now! No Registration Necessary. Now with pictures!
June 27, 2005, 4:24 pm
rate this thread
but have the 0 value last. So, I thought that this should work:
SELECT *, (C-1) AS o from X ORDER BY o;
but it doesn't. Doing a SELECT on (C-1) shows an extremely large
POSITIVE integer value where C=0, as I expected from an UNSIGNED column.
But it is ordered first (as -1). Is this intended behavior? Am I
doing something wrong? I worked around it for now with:
....ORDER BY C>0 DESC, C ASC;
but my curiosity is aroused... And which is faster, anyway?
P.S. Originally (accidentally) posted in m.d.mysql-win32, sorry
Re: ORDER BY problem
Try ORDER BY CAST(C-1 AS UNSIGNED)
You could also use ORDER BY IF(C = 0, 999999999, C)
Why don't you do some timings and tell us which is faster. ;-)
Seriously, many performance issues depend on the distribution of data
values in your database, so the best method of determining which is
fastest is to try it on _your_ database and measure the speed for yourself.
- » How to specify Date format during LOAD DATA INFILE ?
- — Next thread in » MySQL Database Forum
- » Americanas.com SALDO de TVs Com at 80% de Desconto (29798)
- — Newest thread in » MySQL Database Forum