Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
SELECT the previous and next records
Old 12-28-2006, 06:59 PM SELECT the previous and next records
numbenator's Avatar
Webmaster Talker

Posts: 516
Location: London
Trades: 0
HI

Using a select, i want to select the next and previous records and the selected given a primary key = say 911

So , i want to pick up where topic_id = 911 3 records

the 911 record , previous and next

3 records

hope clear

cheers
__________________

Please login or register to view this content. Registration is FREE
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
 
Register now for full access!
Old 12-31-2006, 12:31 PM Re: SELECT the previous and next records
Novice Talker

Posts: 6
Name: !!cuisinart
Trades: 0
Try using following query

Code:
 
SELECT * FROM tabelname
WHERE id > (SELECT max(id) FROM tabelname WHERE id<911)
ORDER BY id
LIMIT 3
__________________

Please login or register to view this content. Registration is FREE
!!cuisinart is offline
Reply With Quote
View Public Profile Visit !!cuisinart's homepage!
 
Old 12-31-2006, 03:16 PM Re: SELECT the previous and next records
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
The query itself won't do it, no matter how you format it.

You would basiclaly create your query to return all records (Select fields from table), then you'd use recordset paging to travers the records to get to where you wanted to get to.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Reply     « Reply to SELECT the previous and next records
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.12159 seconds with 12 queries