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... Quote Link to comment 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 | +-------+ ?? Quote Link to comment Share on other sites More sharing options...
fenway Posted June 24, 2008 Share Posted June 24, 2008 You have no IN/OUT. Quote Link to comment 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.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.