...

View Full Version : Sql_calc_found_rows



BubikolRamios
06-14-2011, 12:59 AM
Anyone using that ?
I mean,SELECT FOUND_ROWS() always returns 1.
Was playing with that in mysql query browser, 1 tab select SQL_CALC_FOUND_ROWS .. limit ..., the other SELECT FOUND_ROWS()
result of second allways 1.
So I pushed thing in stored proc, c_sql of course containing SQL_CALC_FOUND_ROWS,same thing.


in stored proc:


DELIMITER $$

DROP PROCEDURE IF EXISTS `getOnePageOfDataNew` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `getOnePageOfDataNew`(OUT i_result INT,
IN c_sql text,
IN c_limit VARCHAR(60)
)
BEGIN

DECLARE tmpInt INT;

DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
BEGIN
set i_result = -1;
END;

Set @i_count = 0;

SET @s = CONCAT(c_sql," ",c_limit);
prepare stmt from @s;
execute stmt;
DEALLOCATE PREPARE stmt;

SELECT FOUND_ROWS() into @i_count;
set i_result = @i_count;

END $$

DELIMITER ;



by some miracle, this works correct:



Select SQL_CALC_FOUND_ROWS some_field
FROM table
LIMIT 0,18

union

SELECT FOUND_ROWS()



Any explanation, how is this ment to work ?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum