Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2003-08-12 : 07:58:39
|
| Jon writes "The SQL is coming from the product search page. This process is on the product details page and we are getting the “next product” (this is a link). Here is an example of what should happen.Original SQL search.SELECT * FROM [products] WHERE active = ‘Y’ AND aid = 3 ORDER BY sku**Returns 10 rows1 apple2 banana3 cat4 dog5 elephant6 fox7 giant8 hipo9 insect10 jaguarLet’s say the current row is 5. So I would need to return row 6 only.Also the bonus question… let’s say the current row is 10, then row 1 would need to be returned (continually loops).Thank you,Jon C." |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2003-08-12 : 08:34:26
|
The proc used to populate your details page should return the primary key of the 'next'. That way your app can create the appropriate command to call the 'next' details page.select min(pk)from tablewhere pk > @currentpk and other predicates Jay White{0} |
 |
|
|
vganesh76
Yak Posting Veteran
64 Posts |
Posted - 2003-08-12 : 09:13:09
|
| declare @t table (rowno int,prodname varchar(20))insert into @t select 1,'apple'insert into @t select 2,'banana'insert into @t select 3,'cat'insert into @t select 4,'dog'insert into @t select 5,'elephant'insert into @t select 6,'fox'insert into @t select 7,'giant'insert into @t select 8,'hipo'insert into @t select 9,'insect'insert into @t select 10,'jaguar'declare @rowno intselect top 1 @rowno=rowno from @t where rowno > 5if @rowno is nullbeginselect top 1 rowno from @tend elsebeginselect * from @t where rowno=@rownoend V.GaneshNetAssetManagement.Comvganesh76@rediffmail.comEnjoy working |
 |
|
|
vganesh76
Yak Posting Veteran
64 Posts |
Posted - 2003-08-12 : 09:17:09
|
| Please replace the value with the variable.declare @t table (rowno int,prodname varchar(20))insert into @t select 1,'apple'insert into @t select 2,'banana'insert into @t select 3,'cat'insert into @t select 4,'dog'insert into @t select 5,'elephant'insert into @t select 6,'fox'insert into @t select 7,'giant'insert into @t select 8,'hipo'insert into @t select 9,'insect'insert into @t select 10,'jaguar'declare @rowno intDeclare @currentRowNo intset @currentRowNo = 10select top 1 @rowno=rowno from @t where rowno > @currentRowNoif @rowno is nullbeginselect top 1 rowno from @tend elsebeginselect * from @t where rowno=@rownoend Enjoy working |
 |
|
|
|
|
|
|
|