procedures - MYSQL return a single row query with a format -
i got procedure :
delimiter $$ create procedure `countrows`(in v varchar(30)) begin set @t1 =concat("select count(*) ",v); prepare stmt3 @t1; execute stmt3; deallocate prepare stmt3; end$$ delimiter ;
and want return query in format : "the table x contains y rows" tried use concat function don't work me.
some tips? thanks
i able make work using subquery. couldn't find way concat , count search @ same time, wrapping count subquery , using value in select clause able return expected results. try this:
select concat("the table contains ", tmp.numrows, " rows.") from( select count(*) numrows mytable) tmp;
here sql fiddle example of query itself, not prepared statement.
Comments
Post a Comment