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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Help needed on Transact

Author  Topic 

krainov
Yak Posting Veteran

57 Posts

Posted - 2008-10-07 : 04:57:26
Hi there!

I have an array of images in some page of my site - 5 of them in rank! The center image is highlighted as currently viewed. I need to know the IDs of the next & previous images (left & right from central one in this rank) to set these IDs to the next & previous arrows on the page. How can I get these IDs if I have a current ID as a parameter for the SQL-Procedure. Here is my GetImageByID procedure as an example.


ALTER PROCEDURE dbo.tbh_Portfolios_Images_GetImageByID
(
@ImageID int
)
AS
SET NOCOUNT ON

SELECT tbh_Portfolios_Images.ImageID,
tbh_Portfolios_Images.MediaID,
tbh_Portfolios_Images.AddedDate,
tbh_Portfolios_Images.AddedBy,
tbh_Portfolios_Images.OriginalImage,
tbh_Portfolios_Images.OptimizedImage,
tbh_Portfolios_Images.ThumbImage,
tbh_Portfolios_Images.CropImage,
tbh_Portfolios_Images.Title,
tbh_Portfolios_Images.Description,
tbh_Portfolios_Images.ViewCount,
tbh_Portfolios_Images.VoteCount,
tbh_Portfolios_Images.Rating,
tbh_Portfolios_Images.Downloads,
tbh_Portfolios_Images.Comments,
tbh_Portfolios_Images.KeyWords,
tbh_Portfolios_Images.IsCover,
tbh_Portfolios_Medias.Title AS MediaTitle

FROM tbh_Portfolios_Images
INNER JOIN tbh_Portfolios_Medias
ON tbh_Portfolios_Images.MediaID = tbh_Portfolios_Medias.MediaID

WHERE ImageID = @ImageID

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-07 : 05:11:37
Are images displayed as per order of ID value in page?
Go to Top of Page

krainov
Yak Posting Veteran

57 Posts

Posted - 2008-10-07 : 05:17:22
quote:
Originally posted by visakh16

Are images displayed as per order of ID value in page?


ORDER BY AddedDate
Go to Top of Page
   

- Advertisement -