MySQL found_rows ()

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.