Usage of found_rows ():
Example:
CREATE produre TEST (in NAME VARCHAR (#), out number) as
BEGIN
IF NAME is NULL OR name== "Then
SELECT * from EMPLOYEES;
ELSE
SELECT * from EMPLOYEES WHERE first_name like NAME;
END IF;
SELECT found_rows () into number;
END;
On the command line: Call Test (' Test ', @num);
SELECT @num;
You can find the number of rows in your last query;
A simple example:
Mysql> SELECT * FROM Employees limit 10;
+--------+------------+------------+-----------+--------+------------+
| Emp_no | birth_date | first_name | last_name | Gender | hire_date |
+--------+------------+------------+-----------+--------+------------+
| 10001 | 1953-09-02 | Georgi | Facello | M | 1986-06-26 |
| 10002 | 1964-06-02 | Bezalel | Simmel | F | 1985-11-21 |
| 10003 | 1959-12-03 | Parto | Bamford | M | 1986-08-28 |
| 10004 | 1954-05-01 | Chirstian | Koblick | M | 1986-12-01 |
| 10005 | 1955-01-21 | Kyoichi | Maliniak | M | 1989-09-12 |
| 10006 | 1953-04-20 | Anneke | Preusig | F | 1989-06-02 |
| 10007 | 1957-05-23 | Tzvetan | Zielinski | F | 1989-02-10 |
| 10008 | 1958-02-19 | Saniya | Kalloufi | M | 1994-09-15 |
| 10009 | 1952-04-19 | Sumant | PEAC | F | 1985-02-18 |
| 10010 | 1963-06-01 | Duangkaew | Piveteau | F | 1989-08-24 |
+--------+------------+------------+-----------+--------+------------+
Rows in Set (0.00 sec)
Mysql> select Found_rows ();
+--------------+
| Found_rows () |
+--------------+
| 10 |
+--------------+
1 row in Set (0.00 sec)