How can I get the number of rows 'returned' from a result set of a stored procedure
Is there a way to get the number of rows 'returned' from a stored procedure? I know the result set is not really returned so I can't select from it or count on it. I tried to use an out parame开发者_JS百科ter but with no success..
Basically I have some logic in the stored procedure that finds some table lines. I use it in my C# app. in another place I need the exact same logic but only the count so I will be able to use in an SQL statement.
I could bring it to the C# and count there but I prefer not. I could also create a stored function that duplicate the logic but returns COUNT but I prefer not to duplicate so I don't maintain it twice..
Try This found_rows function
http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_found-rows
SELECT COUNT(id) AS example name FROM tablename
精彩评论