Generally we know that '='
operator using for comparison and ':='
for assignment,
But while using with SET
both are working as assignment operator
why?
below stored procedure
for example:
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `substringExample`()
BEGIN
DECLARE x varchar(7);
DECLARE num int;
DECLARE inc int;
SET inc:= 1;
WHILE inc<1400 DO
SELECT SUBSTRING(USER_TEMP_NUM, 8, 13) AS ExtractString
INTO x FROM USER_REGISTRATION_DETAILS where sl_no=inc;
SET num= CONVERT(x,int);
IF (num%2=0) THEN
SELECT num;
END IF;
SET inc:=inc+1;
END WHILE;
END$$
DELIMITER ;
in the above code SET num= CONVERT(x,int);
gives the correct output as well as SET num:= CONVERT(x,int);
I am beginner of stored procedure so dont know at expert level