delimiter //
create procedure elimdato(in id_emple int(6),cp varchar(5))
begin
DELETE FROM empleado WHERE cp=cp;
end //
call elimdato(1,40855);
When executing this procedure, it deletes all the information from the employee table, I would like to know how to delete only the specified data from the column.
The problem is presented to you because you have a field called cp and in the same way you have created a local variable in MySQL that has the same name. This in MySql is an error since the manager ends up interpreting the reference to the table field as the newly created variable.
You are interpreting this as the cp field of the employee table being equal to cp which is the locally defined variable for the stored procedure.
Now MySql "understands" it as the defined local variable cp is equal to the defined variable cp
You solve your problem by changing the name of your local variable to something else. For example:
I hope to be helpful. A greeting!