DELIMITER $$
CREATE DEFINER=`axistms`@`localhost` FUNCTION `CheckDoc`(`orderId` INT) RETURNS int(11)
DETERMINISTIC
BEGIN
DECLARE lvl int;
SELECT count(`id`) INTO lvl FROM `com_carrier_portal_upload_documents` WHERE `orderID`= orderId;
RETURN lvl;
END$$
DELIMITER ;
any order id pass through orderId parameter its doesn't effect on where condition. Always return count of all records.How to fix this?