I am trying to write mysql procedure for below logic,
select id, fullname from users where fullname like concat(lastname, \' \', firstname, \' (\' , middlena
Do a count before the cursor:
select count(*)
into @user_cnt
from users
where fullname like concat (
lastname,
' ',
firstname,
' (',
middlename,
'%'
);
EDIT: If you want to do it after OPENING the cursor, try doing:
OPEN your_cursor;
select FOUND_ROWS() into user_cnt ;
Include SQL_CALC_FOUND_ROWS in your cursor select.Then on fetch use FOUND_ROWS(). It gives the number of records