0
votes

I tired from :

delimiter //
DROP PROCEDURE IF EXISTS tlu30khtd_findkhs //
create procedure tlu30khtd_findkhs(in kehoachso varchar(15)) 
begin
    select *from TLU30KeHoachTuyenDung where KeHoachSo = kehoachso;
end; //
delimiter; 

and when I call procedure with:

call tlu30khtd_findkhs('KH0001')

but result don't use

where KeHoachSo = kehoachso
it display result of
select *from TLU30KeHoachTuyenDung
1

1 Answers

0
votes

The problem is that your parameter name is the same as the column. That means that your where clause doesn't see the parameter, only the column name.

The solution is to prefix parameters. I tend to use p_ or v_:

delimiter //
DROP PROCEDURE IF EXISTS tlu30khtd_findkhs //
create procedure tlu30khtd_findkhs(in p_kehoachso varchar(15)) 
begin
    select t.*
    from TLU30KeHoachTuyenDung t
    where t.KeHoachSo = p_kehoachso;
end; //
delimiter;