fird01 Posted June 24, 2008 Share Posted June 24, 2008 delimiter | create procedure totalmonth(btnid int, mnth int) begin select count(click) as total from eachclick where date like "%-mnth-%" and btn=btnid; end | delimiter; my table would look like this eachclick +--+---+----+--------------+ |bil |btn|click|date | +--+----+----+--------------+ |1 | 2 | 1 | 2008-05-01 | +--+---+----+--------------+ so i create a stored procedure in my database... the thing is.. how do i pass mnth value to the query in procedure... Link to comment https://forums.phpfreaks.com/topic/111615-solved-stored-procedure-how-to-pass-variable/ Share on other sites More sharing options...
fird01 Posted June 24, 2008 Author Share Posted June 24, 2008 anyone?? ok more info..when i use call totalmonth(2,05); it return +-------+ |total | +-------+ | 0 | +-------+ ?? Link to comment https://forums.phpfreaks.com/topic/111615-solved-stored-procedure-how-to-pass-variable/#findComment-573023 Share on other sites More sharing options...
fenway Posted June 24, 2008 Share Posted June 24, 2008 You have no IN/OUT. Link to comment https://forums.phpfreaks.com/topic/111615-solved-stored-procedure-how-to-pass-variable/#findComment-573110 Share on other sites More sharing options...
fird01 Posted June 24, 2008 Author Share Posted June 24, 2008 nope not because in/out thing.. solve it already create procedure totalmonth(btnid integer(10),mnth varchar(10)) begin declare a varchar(20); set @a=concat('%-',mnth,'-%'); select count(click) as total from eachclick where btn=btnid and date like @a ; end eventually when i used call totalmonth(2,05); it not actually passing 05 as the value.. it actually passing 5 as the value... so when i declare the variable as varchar and put a qoute to 05 when calling the procedure call totalmonth(2,"05"); and it worked.. thx anyway.. Link to comment https://forums.phpfreaks.com/topic/111615-solved-stored-procedure-how-to-pass-variable/#findComment-573204 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.