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

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -