MySQL previous next query
| From: | Luis Lebron | Date: | Tue, 06 Feb 2001 00:26:40 +0000 |
| Subject: | MySQL previous next query | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-38338@lists.php.net to get a copy of this message | ||
I need to build a query that needs to find the previous or next record in a
database using a form. The records are numbered using a field called
'sb_num'. This field is initially set using the form.
Would something like this work
Next:
Select 'field1', 'field2' from table order by sb_num where $sb_num>=++sb_num
limit 1
Previous
Select 'field1', 'field2' from table order by sb_num desc where
$sb_num<=--$sb_num limit 1
Luis
lrlebron@home.com