MySQL Forums
Forum List  »  Newbie

break mysql query? Is this possible in my sql
Posted by: Monty Loree
Date: November 21, 2009 03:33PM

I am building a pagination function in mysql & php..
I'm trying to build as much as possible in the mysql engine..

I'm trying to debug my query, and was wondering if it's possible to break the SELECT query while it's building the table if the values don't come out as planned.

code is as follows:
mysql_query("SET @IncrementerA:= 0,@IncrementerB:= 0, @IncrementerC:=0, @IncrementerD:=0,@IncrementerE:=0, @LinkRows:=''");
$sqlstr="SELECT PostID,
@IncrementerA:=@IncrementerA + 1 AS IncrementerA,
@IncrementerB:=@IncrementerB + 1 AS IncrementerB,
@IncrementerC:=@IncrementerC + 1 AS IncrementerC,
@IncrementerE:=@IncrementerE + 1 AS IncrementerE,
@IncrementerE:=@IncrementerE + 1 AS IncrementerE,
IF (@IncrementerB=1, @LinkRows:=CONCAT(@LinkRows,'<tr><td><a href=\"#\">',PostID,'</a></td>\n'),@LinkRows), /*BeginRow*/
IF (@IncrementerA=10 AND @IncrementerB<150, @LinkRows:=CONCAT(@LinkRows,'<td><a href=\"#\">',PostID,'</a></td>\n'),@LinkRows), /*MidRow*/
IF (@IncrementerA=10, @IncrementerD:=@IncrementerD+1,@IncrementerD) AS IncrementerD,
IF (@IncrementerB=150, @LinkRows:=CONCAT(@LinkRows,'<td><a href=\"#\">',PostID,'</a></td></tr>\n'),@LinkRows), /*EndRow*/
IF (@IncrementerB<>150 AND @IncrementerC=(SELECT COUNT(PostID) FROM Pagination) , @LinkRows:=CONCAT(@LinkRows,'</tr>\n'),@LinkRows),
IF (@IncrementerA=10,@IncrementerA:=0,@IncrementerA),
IF (@IncrementerB=150,@IncrementerB:=0,@IncrementerB),
IF (@IncrementerC=(SELECT COUNT(PostID) FROM Pagination),@LinkRows,'') AS LinkRows
FROM Pagination";

Instead of running the full table each time, I would like to break if I'm not getting the right values. I'm not sure if this is possible.. I know that debugging and breaks are easy to do in PHP, but I'm trying to do it mysql.. if possible.


Options: ReplyQuote

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.