I am trying to make a simple project for college assignment. In that,When I am trying to delete a record from a stored procedure in MySQL, that delete statement is deleting all the records.
Here is the code :
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE
`removebus`(in busnumber int,out message varchar(255))
BEGIN
delete from fare where busnumber = busnumber;
delete from bus where busnumber = busnumber;
set message = 'success';
else
set message = 'not found';
end if;
END
And I am executing like call removebus(1,@message);
.
When I am trying to only execute the delete statement from command window, then it is deleting one record only but when I executed the call statement, all the records are deleted from my table. Just to add, busnumber is primary key of bus table. I am not able to understand why.