|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Going back or forward 1 record
Does anyone know how to go back 1 record?
I know how to go forward 1 record: Code:
SELECT TOP 1 * FROM MyTable WHERE [id] > 27 ORDER BY [id] This will select the record with the id 28, if id 28 does not exist, then it will select the next available id. however, then I try: Code:
SELECT TOP 1 * FROM MyTable WHERE [id] < 27 ORDER BY [id] It goes to the very first record in the table, becuase it selecting the TOP 1 record, How do I only go back 1 record, eg. id 26. |
|
#2
|
|||
|
|||
|
Code:
SELECT TOP 1 * FROM MyTable WHERE id < 27 ORDER BY id desc |
|
#3
|
|||
|
|||
|
I never see the obvious. Thanks a lot
![]() |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Going back or forward 1 record |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|