[thelist] Quick SQL question
Austin Govella
austin at desiremedia.com
Mon Feb 10 15:19:01 CST 2003
> I want the last 15 or so records from my table, so I try this:
>
> SELECT TOP 15 *
> FROM MyTable
> ORDER BY Col_ID DESC
>
> but this returns
>
> 255
> 254
> 253
> 252
> 251
>
> I want it to return
>
> 251
> 252
> 253
> 254
> 255
I read the answers, but I don't understand why you couldn't just change
the ORDER from DESC to ASC.
In my logic (being familiar with basic SQL and sketchy beyond that), the
TOP 15 gets the 15 highest numbers from the col_id (done in numbers). And
the ORDER BY decides whether it goes from highest to lowest or vice versa.
Additionally, since I'm asking...
Why can't you:
SELECT *
FROM MyTable
LIMIT 15
ORDER BY col_id ASC
Would this provide the same data?
Just trying to ferret through this SQL mumbo-jumbo,
--
Austin
More information about the thelist
mailing list