I've got a mySql stored procedure that looks like this--
delimiter |
create procedure GetEmployeeById(in ID varchar(45))
begin
select id,
firstName,
lastName,
phone,
address1,
address2,
city,
state,
zip,
username,
password,
emptypeid
from myschema.tblemployees t
where
t.id=ID limit 1;
end |
delimiter;
If i don't have the limit 1 in place, it always returns all of the rows in the table--with each record's id value set to the ID parameter. Why can't i just use where id=ID, and why does it return all of the records when i do? What are the implications of me using limit 1? Why am i programming on a saturday night?
Because, it's comparing t.id with itself, which will always be true. Call your formal parameter something else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With