Thread: MySQL problem
View Single Post
Old 05-06-2002, 02:22 PM  
Tipsy
Confirmed User
 
Join Date: Jul 2001
Location: See sig
Posts: 6,989
Quote:
Originally posted by XXXManager
Tipsy. Your questions is a little misleading...
There is no such thing as a position in tables - in relational databases. You can not say a record is the 10th (or whatever) record in a table (or a select). The fact that a record is the 1st or 10th in a select that is NOT an "ORDER"ed select is a matter a chance and you SHOULD NOT - under any circumstances - count on it being consistently so..
I recommend the folowwing...
1) order(sort) the table by someithing - anything would do if you dont have a valid field (like ID). "ORDER BY ____ [DESC]". ____ is a field name, DESC is optional for reverse ordering
2) LIMIT x,y - like boldy suggested will give you the -1 record after skipping x records. -1 records means: 1 record BACK. if you do LIMIT 10,5 meains records 11..15 in the select result.

Not using ORDER is also legitimate but DONT count of results being consistent. It will probably be so, but if you "check" the table or restore it from backup - results may change. actually ORDER is quite natural in many/most queries anyway - but if you dont care about consistency - not using ORDER may save you time/cpu
Fair point. Thanks for the clarification
__________________
Ignorance is never bliss.
Tipsy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote