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?
I'd suggest you to rename stored procedure argument, do something like this -
CREATE DEFINER = `axistms`@`localhost` FUNCTION `CheckDoc` (orderIdParam int)
RETURNS int(11)
DETERMINISTIC
BEGIN
DECLARE lvl int;
SELECT
COUNT(`id`) INTO lvl
FROM `com_carrier_portal_upload_documents`
WHERE `orderID` = orderIdParam;
RETURN lvl;
END
...because WHERE orderID
= orderId can be equal to WHERE true.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.