Hi Developers,
For selecting random records i found this stored Procedure i am not able to understand it. Please help me........
I am using Sql Server Database ...
DELIMITER $$
USE `vtest`$$
DROP PROCEDURE IF EXISTS `sp_random`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_random`(OUT result VARCHAR(50))
BEGIN
DECLARE rques VARCHAR(50);
DECLARE resultnotfound VARCHAR(50);
DECLARE crsrresult CURSOR FOR SELECT question FROM test WHERE done=0 ORDER BY RAND();
DECLARE CONTINUE HANDLER FOR NOT FOUND SET resultnotfound ='NO more quesstions';
OPEN crsrresult;
FETCH crsrresult INTO rques;
IF rques='' THEN
SET result=resultnotfound;
ELSE
UPDATE test SET done=1 WHERE question=rques;
SET result=rques;
END IF;
CLOSE crsrresult;
END$$
DELIMITER ;
Thanks & Regards
iluvdotnetfunda