Skip to main content
gamedev.net
🔒 Locked

[web] SQL (mySQL) help

Started by yanuart Jul 5, 2004 at 8:13 PM 0 replies 550+ views
Original Post
yanuart
yanuart
hi does anyone know to select for ex. I have a record and I want to select records below and above it so that it always ten records showing. A good example for this app is a highscore table, if I just enter a record, then I want to query all the records above and under me to know exactly where is my position on the table and it always show 10 records at the time. So if I just made top of the list i only need to query records under me and vice versa.. Can this be done using select command ?? or I need to manually select them (problaly costs me 3 select)??
Ride the thrill of your life
Play Motorama
Michalson
Michalson
That really depends. What is the table structure and data? If you have a field that indicates your exact position (1,2,3,etc) then you can easily check for the top constraint when making the query. Without being able to tune to the exact situation the best solution would be to just grab 19 records (up to 9 before, 9 after), and discard the extras. The overhead in grabbing 9 extra records is tiny compared to the overhead of setting up and running 2 more queries. While you could contruct a really complex query that only returns the exact 10 records required, the fact that you are using MySQL will make it slower then the discard solution.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.