artman41
artman41

Reputation: 404

Why is my procedure returning a different value from my query?

The procedure that is not returning correctly is the following:

CREATE DEFINER=`hs`@`%` PROCEDURE `GetUser_id`(in id int)
BEGIN
    select * from hackstart.users where ID=id;
END

which I call using

call GetUser_id(2);

I expect this to return the same as

select * from hackstart.users where `ID` = 2;

which returns a single row. However, the procedure returns the entire table. Can anyone point out where I went wrong and why it's incorrect.

Upvotes: 1

Views: 65

Answers (1)

artman41
artman41

Reputation: 404

As Ryan and xQbert said, the issue was that the parameter had the same name as the column name, which is an issue due to case-insensitivity

Upvotes: 2

Related Questions