This is a discussion on Need help with Paging Sproc within the MySQL forums, part of the Database Server Software category; --> Hi. I have a select statement below that I am using on my search page and would like to ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi. I have a select statement below that I am using on my search page and would like to add paging to it: SELECT CONCAT("<a href=\"javascript:NewWindow('live.aspx? sid=70','mypopup','1024','768','center','front');\ "><u>",s.title,"</ u></a>", LEFT(CONCAT('<p>',s.Description,'</p>'), 100)) AS Events, c.StartDate As Date, c.ScheduleType As Type, c.ScheduleType As Status, p.DisplayName As Presenter from schedulemetadata s, commonschedule c, presenter p where c.ScheduleID = s.ScheduleID and c.ScheduleID = p.ScheduleID; Feel free to poke at the above script as I feel it could use some analysis. Namely, is my "where" clause going to bugger things? I don't feel that this is correct. Next, after some hunting on the internet, I found a SPROC that I would like to use for paging: (credit: http://www.informit.com/articles/art...32056&seqNum=3) CREATE PROCEDURE sp_PageThroughData ( @PageSize int, @CurrentPage int ) AS CREATE TABLE #SearchTable ( IncreasingID int IDENTITY(1,1), OtherID int ) -- Now, populate the temporary table INSERT INTO #SearchTable (OtherID) SELECT CommentID FROM Comments ORDER BY CommentID ASC -- Finally, return the records SELECT IncreasingID, Comments.* FROM #SearchTable INNER JOIN Comments ON Comments.CommentID = #SearchTable.OtherID WHERE IncreasingID > @PageSize * @CurrentPage AND IncreasingID <= @PageSize * (@CurrentPage+1) My problem is that the INSERT INTO statement in the example is very clean and simple. One Table, one ID. Very nice. But, my select statement has numerous joins and is not so straight forward. It is not obvious to me how to apply my select statement to this example. Would somebody mind showing me how my script can be applied to the paging example? I am new to mysql and could use some help/advice/ guidance - whatever you are willing to provide. Thanks, Peter |