mysql - SELECT inside stored proc doesn't work correctly whereas outside it does -
i have simple database follows in mysql:
drop table if exists mediavend.itemdetails; create table if not exists mediavend.itemdetails ( itemid bigint unsigned not null, itemtype enum('music', 'movie', 'game') not null, itemmediatype enum('cd', 'dvd', 'bluray') not null, itemname char(100) not null, itemdescription char(200) not null, itemcount bigint not null, machineid bigint not null, primary key (itemid) ); insert mediavend.itemdetails values (1,'music','cd','album 1','some description of 1',100,1), (2,'music','cd','album 2','some description of 2',20,1), (3,'movie','dvd','movie 1','some description of 1',30,1), (4,'movie','bluray','movie 2','some description of 2',40,1), (5,'game','dvd','game 1','some description of 1',50,1), (6,'game','bluray','game 2','some description of 2',60,1);
and stored proc :
delimiter $$ create definer=`root`@`localhost` procedure `info_itemtype`(in itemtype char(10)) begin select * mediavend.itemdetails itemtype= itemtype; end
so when call following see different results.
select * mediavend.itemdetails itemtype='music';
-- 2 rows returned
call mediavend.info_itemtype('music');
-- 6 rows returned
i baffled, pardon me if silly mistake, have gone through lots of questions , don't see relevant this.
rename input parameter since has same name column.
delimiter $$ create definer=`root`@`localhost` procedure `info_itemtype`(in itemtype_param char(10)) begin select * mediavend.itemdetails itemtype = itemtype_param; end $$
Comments
Post a Comment